One does not simply...

The number 111111 is formed by repeating the number one 6 times (duh). A code was fed this as its input. (nom nom). The code runs as follows:

IF the number is divisible by 11, it divides the number by 11.

ELSE IF the number consists of only 1s and 0s, the number is converted from this "binary" like form to its decimal form.

ELSE add the number '1' at the end of the number.

The code continues running for 100 loops throughout all 3 possibilities or until the number reaches 1.

For example, the number 10 when fed to the code becomes 2. That's the first time it loops.

Then, since the number 2 is not divisible by 11 and does not consist of only 1s and 0s, we add a 1 behind, making it 21. This process continues for 98 more times.

Find the number of digits of the result when the code is fed 111111.

(Example if the result is 12345, your answer is 5)


The answer is 100.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

2 solutions

David Holcer
Mar 15, 2015
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
#One does not simply...
num=111111
for i in range (100):
    if num !=1:
        if num%11==0:
            num/=11
        elif ((str(num).count('0')+str(num).count('1'))==len(str(num))):
            num= int(str(num), 2)
        else:
            num=int(str(num)+'1')
print len(str(num))

Ronak Agarwal
Sep 5, 2014

Seriously is it a computer science question. One can easily see that running loop first time we will get 10101 and the running another time we will get 21. Now the next 98 times it will only add 1 at the end continously resulting in a number 211.......(1 occuring 99 times) of 100 digits.

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...