Divisible by 99?

What is the smallest number which consists of the digits 1 through 9 exactly once and is divisible by 99?


The answer is 123475869.

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

Michael Mendrin
Apr 19, 2016

First, since the sum of the digits from 1 1 to 9 9 is divisible by 9 9 , any permutation is divisible by 9 9 , so we only need to look at divisibility by 11 11 . A well known digit test for that is do an alternating sum of the digits, which , if divisible by 11 11 , will mean that the number itself is also divisible by 11 11 . So, we start with the smallest possible number and check this sum

1 2 + 3 4 + 5 6 + 7 8 + 9 = 5 1-2+3-4+5-6+7-8+9=5

which means it's not divisible by 11 11 , and we need to make the sum divisible by 11 11 . We can change the sum only by transposing some of the digits, and they need to be of a different sign to make a difference. However, the difference in the sum will always be an even number, so it's pointless to do transposes that reduces the sum (can't get from 5 5 to 0 0 ), so we look for transposes that raises it. We focus on the digits to the far right. We transpose the furthest right digits that will do the job immediately

1 2 + 3 4 + 8 6 + 7 5 + 9 = 11 1-2+3-4+8-6+7-5+9=11

and then we rearrange to get the smallest possible number (sort them in each sign group)

1 2 + 3 4 + 7 5 + 8 6 + 9 = 11 1-2+3-4+7-5+8-6+9=11

Thus we end up with 123475869 123475869 which is divisible by 99 99 .

Yea, the divisibility by 11 is the tricky part. Even after identifying what must be done, there are still various arguments that need to be made in order to minimize the final value that we obtain.

Calvin Lin Staff - 5 years, 1 month ago

I did the same too

Aditya Kumar - 5 years, 1 month ago

You know that the sum of digits is going to be 45, and so there are only a few ways to do the divisibility test for 11(since it's always going to be divisible by 9). To get odds-evens to be 11, sum of odds must be equal to 28, it's impossible to get odds-evens=0. There are very few combinations to get odds sum of 28, and one of them is the answer. I know that this is not a solution but it's some insight.

Arjun Pherwani - 3 years, 6 months ago

What trickery is this? They title SPECIFICALLY says "from 1 (...) to 99" and the answer is f ** 123475769? Are you mocking us? The problem is bloody impossible if the answer is between 1 and 99. Stop inventing pretty and original names and either give a RELEVANT title or NO title at all. Ugh... I'm so mad at this...

Luis Paulo - 5 years, 1 month ago

Log in to reply

Thanks for your feedback. I have removed the title "From 1 to 9 to 99" since there are possible misinterpretations of what it means.

Please be respectful of the community when typing comments.

Calvin Lin Staff - 5 years, 1 month ago

Log in to reply

Sometimes when one tries to be too clever, there's blowback, huh? I guess the movie, "From Here to Eternity" has gotten some viewers angry because it never got to eternity.

Michael Mendrin - 5 years, 1 month ago

Question could have better be asked as:What is the smallest number consists of 9 distinct digits and containing each of 1 to 9 exactly once?

vinod trivedi - 5 years, 1 month ago

Wow, harsh!

Michael Mendrin - 5 years, 1 month ago

you are totally right, harsh thou. I really didn't understand the problem too!

Rama Essam - 5 years, 1 month ago

Relevant wiki: Divisibility Rules (2,3,5,7,11,13,17,19,...)

As the numbers 9 9 and 11 11 are coprime, we can say that n n is divisible by 99 99 iff it's divisible both by 9 9 and 11 11 . As all the numbers consisting digits 1 1 through 9 9 exactly once are divisible by 9 9 (because the sum of the digits is divisible by 9 9 ), we are looking for the smallest n n consisting each digit exactly once and being divisible by 11 11 .

Let's denote the odd position digits of n n by A A and even position digits by B B such as n = ( A 1 B 1 A 2 B 2 A 3 B 3 A 4 B 4 A 5 ) . n = (A_1B_1A_2B_2A_3B_3A_4B_4A_5)\mbox{.}

The divisibility rule for 11 11 tells us that A B 0 ( m o d 11 ) \sum A - \sum B \equiv 0 \pmod{11} . Because the divisibility does not depend on the order of digits within A A and within B B , the immediate conclusion from the minimality constraint for n n is that A 1 < A 2 < A 3 < A 4 < A 5 A_1<A_2<A_3<A_4<A_5 and B 1 < B 2 < B 3 < B 4 B_1<B_2<B_3<B_4 .

Because A + B = 45 \sum A + \sum B = 45 , we can rewrite the congruent equation as ( 45 B ) B 0 (45 - \sum B) - \sum B \equiv 0 . This gives us 2 B 1 2\sum B \equiv 1 and B 6 ( m o d 11 ) \sum B \equiv 6 \pmod{11} .

Also we have: 10 = 1 + 2 + 3 + 4 B 6 + 7 + 8 + 9 = 30 10 = 1+2+3+4 \leqslant \sum B \leqslant 6+7+8+9 = 30 and this with the congruent equation gives us two solutions: B = 17 \sum B = 17 or B = 28 \sum B = 28 .

Let's look at the solutions where n n starts with 1234 1234 . We have ( B 1 , B 2 ) = ( 2 , 4 ) (B_1, B_2) = (2, 4) . If B = 28 \sum B = 28 then B 3 + B 4 = 22 B_3+B_4=22 and there are no solutions amongst single digits.

If B = 17 \sum B = 17 then we have B 3 + B 4 = 11 B_3+B_4=11 (and of course 4 < B 3 < B 4 < 9 4<B_3<B_4<9 ). This gives us the only solution B = ( 2 , 4 , 5 , 6 ) B = (2,4,5,6) and the final solution n = 123475869 n=123475869 .

We have found the only solution starting with the digits 1234 1234 , thus we can conclude it's the minimal one.

Beautiful solution!

Katherine Henrici - 4 years, 1 month ago
PradyGame Dev
Apr 28, 2016

I'm really sorry, I thought this was a Computer Science problem. Though I got how to do it manually, here's the Python code anyway.

import itertools
string = "123456789"
numbers = [int("".join(x)) for x in itertools.permutations(string) if int("".join(x))%99==0]
numbers.sort()
print numbers[0]

We could also say:

print min(int("".join(x)) for x in itertools.permutations(string) if int("".join(x))%99==0)

Abdelhamid Saadi - 4 years, 3 months ago
Xúc Xích Đức
Jul 25, 2018

Please change the word usage, I did not know that I have to use all the digits from 1 to 9 >_<

The problem states "consists of the digits 1 through 9 exactly once".

Which part of that should be edited to reflect "have to use all the digits from 1 to 9"?

Calvin Lin Staff - 2 years, 10 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...