Do you know my Phone number?

During a talk with Aditya Raut on slack, Aditya asked Mehul for his phone number. Mehul tried to play a trick with Aditya, he gave Aditya some hints about his phone number:

  • In my phone number, none of the digit repeats.

  • It is a 10 10 digit number.

  • The first n n digits of that number. are divisible by n n . For example: first 5 5 digits are divisible by 5 5 , first 6 6 digits are divisible by 6 6 and so on.

  • First digit is not 0 0 .

  • All the digits are positive integers.

After some time Mehul got a call from Aditya, which signified that Aditya has conquered Mehul's trick(although it was very easy for Aditya, being a genious).

Now it's your turn Brilliantians, just go for it .and find my secret Phone number


The answer is 3816547290.

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.

4 solutions

Anis Abboud
Mar 26, 2015

If you want the easy way, here's a simple Python code:

1
2
3
4
5
from itertools import permutations

for permutation in permutations('0123456789'):
  if all(int(''.join(permutation[:i])) % i == 0 for i in range(1, 11)):
    print ''.join(permutation)

The code above is inefficient, because it goes through all the 10 ! = 3 , 628 , 800 10! = 3,628,800 permutations. Note that you have to have even digits in all even places, because an odd number isn't divisible by an even digit, so you could use this information to optimize the code and get:

1
2
3
4
5
6
7
from itertools import permutations

for odds in permutations('13579'):
  for evens in permutations('02468'):
    permutation = [x for pair in zip(odds, evens) for x in pair]
    if all(int(''.join(permutation[:i])) % i == 0 for i in range(1, 11)):
      print ''.join(permutation)

That goes through 5 ! 5 ! = 14 , 400 5! \cdot 5! = 14,400 permutations (252 times faster).

But it's still cheating, so let's do it manually.


Let [i] denote the i'th digit, and [ijk] denote the i'th and j'th and k'th digits.

(1) Note that the last digit [10] has to be 0. Otherwise the number won't be divisible by 10.

(2) [5] has to be 0 or 5, in order for [12345] to be divisble by 5. Since [10]=0, we get [5]=5.

(3) [123] has to be divisible by 3, and [123456] has to be divisible by 6. Note that this implies that [456] has to be divisible by 3. We know that [5]=5, and we also know that [4] and [6] have to be even.

So, [4]+5+[6] is divisible by 3, and [4] + [6] are even \Rightarrow ([4] + [6]) % 3 = 1 and ([4] + [6]) = even \Rightarrow [4] + [6] = 4 or 10 or 16.

4 is impossible because it can only be 2+2 (duplicate), and 16 is impossible because it can only be 8+8 (duplicate), so [4]+[6] = 10. So they can be either 2 and 8, or 4 and 6.

(4) [34] has to be divisible by 4. Also, 3 is odd. So [4] has to be 2 or 6 (try it: 12, 16, 32, 36, ...) So [456] have to be 258 or 654.

(5) [678] has to be divisible by 8. [7] is odd, and [6] is either 4 (and then [8] can only be 2 or 8) or 8 (and then [8] can only be 4 or 6).

So there's only a few options for [678]: 432, 472, 816, 896... (I made a mistake earlier, so ) I will consider only 432 and 472 here. The other options 816 and 896 are addressed in my comment below.

So [8]=2. Therefore, [456] cannot be 258, and can only be 654. Therefore, [678] is either 432 or 472. Also, there's only one option left for [2], and that is 8.


That's a lot, so let's recap what we know.

  • [1]=1 or 3 or 7 or 9
  • [2]=8
  • [3]=1 or 3 or 7 or 9
  • [4]=6
  • [5]=5
  • [6]=4
  • [7]=3 or 7
  • [8]=2
  • [9]=1 or 3 or 7 or 9
  • [10]=0

(6) Let's now take a look at [123]. It's divisible by 3, so [1]+8+[3] is divisible by 3, so [1]+[3] % 3 = 1. We also know that [1]+[3] is even because they are both odd. So there's only a few options for [1]+[3]: 4, 10, 16. So [13] has 6 options: 13, 31, 37, 73, 79, 97.

(7) Let's consider [1234567]. It has to be divisible by 7. There are 6 options for [13] and 2 options for [7]. So, 12 total - we can check these manually.

  • 1836543 % 7 = 2
  • 1836547 % 7 = 6
  • 3816543 % 7 = 3
  • 3816547 % 7 = 0
  • 3876543 % 7 = 6
  • 3876547 % 7 = 3
  • 7836543 % 7 = 3
  • 7836547 % 7 = 5
  • 7896543 % 7 = 4
  • 7896547 % 7 = 1
  • 9876543 % 7 = 5
  • 9876547 % 7 = 2

So [1234567] = 3816547. We also know that [8]=2 and [10]=0, so [9]=9 (only option left).

Therefore, the number is 3816547290 \boxed{3816547290} .

@Anis Abboud . Amazing solution!!!!!!Upvoted.

Mehul Chaturvedi - 6 years, 2 months ago

Log in to reply

Thank you!

Anis Abboud - 6 years, 2 months ago

In step 5, why can't we have [678] be something like 816 or 496? Why does [7] have to be 3 or 7?

Jared Low - 6 years, 2 months ago

Log in to reply

Hi Jared, thanks for asking and good point!

Recall from step (3) that [4] and [6] can be either 2 and 8, or 4 and 6. Therefore, [678] cannot be 496 because when [6]=4, we get [4]=6 and then [8] can't be 6 as well.

For the same reason, 832 and 872 are not possible either (when [6]=8, we get [4]=2 and then [8] can't be 2 as well). So I made a mistake here. Instead of these, I should have had 816 (which you suggest), 856 (impossible because 5 is already taken), and 896.

To sum up, these are the options for [678]: 432, 472, 816, 896.

My solution considers 432 and 472. To fix it, we need to consider 816 and 896 and redo steps 5-7 accordingly.

(5) If [678] = 816 or 896 then [6]=8, [7]=1 or 9 and [8]=6. So from step (3) we get [2]=4 and [4]=2.

  • [1]=1 or 3 or 7 or 9
  • [2]=4
  • [3]=1 or 3 or 7 or 9
  • [4]=2
  • [5]=5
  • [6]=8
  • [7]=1 or 9
  • [8]=6
  • [9]=1 or 3 or 7 or 9
  • [10]=0

(6) Let's now take a look at [123]. It's divisible by 3, so [1]+4+[3] is divisible by 3, so [1]+[3] % 3 = 2. We also know that [1]+[3] is even because they are both odd. So there's only a few options for [1]+[3]: 8 and 14. So [13] has only two options: 17, 71 (note that we can't use 5 as it's already used for [5]).

Looking back at the list of options above, we see that [7] has to be 9, because 1 will be used for [1] or [3]. Then, [9] has to be 3.

  • [1]=1 or 7
  • [2]=4
  • [3]=7 or 1
  • [4]=2
  • [5]=5
  • [6]=8
  • [7]=9
  • [8]=6
  • [9]=3
  • [10]=0

(7) That leaves 2 options for [1234567]: 1472589 and 7412589, which are not divisble by 7, so we can't continue along this path. So [678] has to be 432 or 472 and my solution explains how to continue from there.

Anis Abboud - 6 years, 2 months ago

Log in to reply

Great edit to your solution!

Jared Low - 6 years, 2 months ago
Andrea Palma
Mar 29, 2015

10th digit must be 0, so the fifth digit can't be other than 5.

Even place digit mut be even. As a consequence odd place digit have to be odd.

It is a fact that a multiple of 4 (and hence a multiple of 8) must have as its last digit an even number, and if the digit just before the last is odd then the last digit must be 2 or 6.

We have one of the two following configurations

_ _ _ 2 5 _ _ 6 _ 0

_ _ _ 6 5 _ _ 2 _ 0

For the divisibility-by-3 criterion the groups of the first three and second three digit (and hence also the third group of 3 digit) must sum up to a multiple of 3.

We can add a digit on sixth place of each possibility, and the last even digit to the second to get:

_ 4 _ 2 5 8 _ 6 _ 0

_ 8 _ 6 5 4 _ 2 _ 0

Let's spend the divisibility by 8 criterion. Since

_ 4 _ 2 5 8 _ 6 = _ 4 _ 2 5 0 0 0 + 8 _ 6

_ 8 _ 6 5 4 _ 2 = _ 8 _ 6 5 0 0 0 + 4 _ 2

and any multiple of 1000 is divisible be 8, it must be for the first case

8 _ 6 divisible by 8

and for the second case

4 _ 2 divisible by 8

This leaves only the following possibilities

_ 4 _ 2 5 8 1 6 _ 0

_ 4 _ 2 5 8 9 6 _ 0

for the first combination and

_ 8 _ 6 5 4 3 2 _ 0

_ 8 _ 6 5 4 7 2 _ 0

for the second combination.

Since the first group of three digit sums up to a multiple of 3

we only have these chances

1 4 7 2 5 8 9 6 3 0 (fails 7 test) and 7 4 1 2 5 8 9 6 3 0 (fails 7 test)

for the first combination. while, for the second,

1 8 9 6 5 4 3 2 7 0 (fails 7 test) 9 8 1 6 5 4 3 2 7 0 (fails 7 test)

1 8 9 6 5 4 7 2 3 0 (fails 7 test) 9 8 1 6 5 4 7 2 3 0 (fails 7 test)

1 8 3 6 5 4 7 2 9 0 (fails 7 test) 3 8 1 6 5 4 7 2 9 0

7 8 9 6 5 4 3 2 1 0 (fails 7 test) 9 8 7 6 5 4 3 2 1 0 (fails 7 test)

So the only possibility left is 3816547290.

Nice solution!

Anis Abboud - 6 years, 2 months ago

Log in to reply

THANKS a lot! I just shortened the proof using the divisibility per 8 of the first 8th digits that gives a great hint on the 8th digit that reduces a lot the examitation of cases one by one.

Andrea Palma - 6 years, 2 months ago
Sharky Kesa
Mar 31, 2015
Aditya Raut
Mar 26, 2015

Here's my programming solution, but I used bit maths to make it better, by using the divisibility tests of 2 , 4 , 5 , 6 , 8 2,4,5,6,8

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
from itertools import permutations
for i in permutations('0123456789'):
    k=''.join(i)
    if k[9]=='0':
        a=k[0]
        b=k[1]
        c=k[2]
        d=k[3]
        e=k[4]
        f=k[5]
        g=k[6]
        h=k[7]
        if int(b)%2==0 and int(a+b+c)%3==0 and int(c+d)%4==0 and int(e)%5==0 and int(d+e+f)%6==0 and int(a+b+c+d+e+f+g)%7==0 and int(f+g+h)%8==0:
            print k

This printed for me, the answer as 3816547290 \boxed{3816547290} , not too long time...

@Mehul Chaturvedi , you never gave me your number :(

But if you want mine, I've made a way tougher problem (in terms of comp.sci)....

Getting my number is tough, let's see if I get a call from you.... All buzzkill for 1 number

Aditya Raut - 6 years, 2 months ago

Log in to reply

I can just give it a try...but ,never sure , of getting it correct...Though I'm out of station ,but will try to do it on android....quite messy @Aditya Raut .

Mehul Chaturvedi - 6 years, 2 months ago

Log in to reply

class phone_no

{

void sum()

{

    int n,r;

    int s1,s2,s3,s4,s5,s6,s7,s8,s9;

    for(int i=100000000 ; i<=999999999;i++)

    {

        String s = String.valueOf(i);
        int l=9,flag=0;
        for(int k=0;k<l-1;k++)
        {
            for(int j=k+1;j<l;j++)
            {
                if(s.charAt(k)==s.charAt(j))
                {  flag=1;
                    break;
                }
            }
        }
        if (flag==0)
        {
            s2=i/10000000;
            s3=i/1000000;
            s4=i/100000;
            s5=i/10000;
            s6=i/1000;
            s7=i/100;
            s8=i/10;
            s9=i;
            if (s9%9==0&&s8%8==0&&s7%7==0&&s6%6==0&&s5%5==0&&s4%4==0&&s3%3==0&&s2%2==0)
                System.out.println(i); 
        }
        flag=0;
    }
}

}

This Java program gives four output numbers (each with 9 digits). Now we know that the last digits must be zero and so none of the other digits can be zero, then we can eliminate three of the numbers. only one remains, to which we add 0 to the end and get 3816547290.

Aditya Paul - 6 years, 2 months ago

So....then,I think that I should edit the problem :-\ @Aditya Raut

Mehul Chaturvedi - 6 years, 2 months ago

I will surely give u a call ;-) , when i would reach home and get my PC back @Aditya Raut

Mehul Chaturvedi - 6 years, 2 months ago

India's area code is 91 , I don't see a 91 91 in front of the answer. You're lying, Aditya!

Pi Han Goh - 6 years, 2 months ago

Log in to reply

Yeah, previously I had added a statement at the end of problem, it was "I live in India".... But then I felt people might really call me so I removed that statement...

I can't believe THE PI HAN GOH replied to my comment! I'm not lying, I can for sure like a call from you, it'll be a "12" digit number, add + 91 +91 before the 10 digit answer, call it...

Aditya Raut - 6 years, 2 months ago

Log in to reply

@Aditya Raut I don't see a " 38 38 " in the second column after 91 91 either! Stop falsifying claims!

I checked with another source too !

Pi Han Goh - 6 years, 2 months ago

Log in to reply

@Pi Han Goh I can't leak the answer here, you'll have to dial + 91 x x x x x x x x x x +91xxxxxxxxxx (the 10 digit number preceded by + 91 +91 .... If no belief, try it ;)

Aditya Raut - 6 years, 2 months ago

Log in to reply

@Aditya Raut OH MY GOD IT WORKED! ¨ \ddot\smile

Pi Han Goh - 6 years, 2 months ago

Log in to reply

@Pi Han Goh I didn't get a call though... you tried on some website? Where?

Aditya Raut - 6 years, 2 months ago

@Aditya Raut Oh , so it really is what I thought it was ! You mind if I call you ?

A Former Brilliant Member - 6 years, 2 months ago

I agree that 3816547290 is possible.. I got it the first time... But this is not the only solution possible!!

Check this number 9816543270

Arunima Mitra - 5 years, 10 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...