Find the largest 7-digit number without its digits repeating, such that the number is divisible by all of its digits

I found some constraints: • 0,4 and 5 cannot be included • The number found should be even • It is enough to check whether the number formed with the digits I excluded be divisible by 7 and 8.

I am not able to proceed any further.

  • $\begingroup$ Why must it be even? $\endgroup$ Sep 29, 2016 at 14:44
  • 1
    $\begingroup$ @greenturtle3141 Because if you're using 7 distinct digits, you need to include at least one even digit. This digit must be a divisor of the number as a whole, implying the number itself is even. (Odd numbers don't have even divisors.) $\endgroup$ Sep 29, 2016 at 15:08
  • 4
    $\begingroup$ @Marius Those aren't the same question at all... $\endgroup$
    – Sconibulus
    Sep 29, 2016 at 15:14
  • $\begingroup$ @Sconibulus The linked question is a mathematical formulation of this one. $\endgroup$
    – user20
    Sep 29, 2016 at 20:43
  • 1
    $\begingroup$ @Sconibulus Oh, whoops, you're totally right. $\endgroup$
    – user20
    Sep 29, 2016 at 21:07

2 Answers 2


The answer is


You can check the divisibility rules

Even- divisible by 2, sum of digits=36, divisible by 3 and 9. Divisibility with 2 and 3 shows that it is divisible by 6. Last 3 digits show divisible by 8. You can simply check the divisibility by 7 by simply dividing. P.S. Here's the link for the answer https://math.stackexchange.com/questions/1362741/numbers-divisible-by-all-of-their-digits-why-dont-4s-show-up-in-6-or-7-digi

  • 1
    $\begingroup$ ^vote with an note: Perfect cross reference but no mention of why this number is the largest. $\endgroup$
    – humn
    Sep 29, 2016 at 17:36
  • $\begingroup$ @humn Well, that I wasn't too sure about, myself. I supposed that someone would probably write a code for it. Although, I could somewhat defend it by pointing that it is probably close to the largest 7 digit number.. $\endgroup$
    – Sid
    Sep 29, 2016 at 17:40
  • $\begingroup$ @humm, LCM of 6, 7, 8, 9 is 504, so there can't be a 7 digit number that fits the criteria better. $\endgroup$
    – TheChetan
    Sep 29, 2016 at 17:58
  • $\begingroup$ @TheChetan So, how does that prove anything? A bit further explanations for me at least, so that I can edit in your explanation.. $\endgroup$
    – Sid
    Sep 29, 2016 at 18:00
  • $\begingroup$ @humn, the link to math.stackexhange proves that the number should contain 6, 7, 8 and 9. $\endgroup$
    – TheChetan
    Sep 29, 2016 at 18:03

Sid already told us what the answer is, but let's see if we can prove it without a computer search. Knowing what answer we're looking for will help to guide our choice of things to prove, but I won't exploit this too much.

So, let's see whether our number can begin 987. If so, it looks like 987xxxx and must be a multiple of 9x8x7=504.

It can't contain a 0 because the only thing divisible by 0 is 0. It can't contain a 5 because it's even, and being divisible by 0 and 5 means being divisible by 10 which means ending in 0, which we just saw was impossible.

So our remaining four digits are four out of {1,2,3,4,6}. The sum of all the digits is going to have to be a multiple of 9, so the sum of these four has to be 3 mod 9, whereas the sum of all five is 7 mod 9, so the missing one needs to be 4. So now we need 987xxxx where the xxxx are 1236 in some order; and the number (hence the xxxx alone) needs to be a multiple of 7 and of 8. From the fact that it's a multiple of 4 we deduce that it ends [odd][even], and then the multiples of 8 are 3216 2136 6312 1632. None of these is a multiple of 7.

So, our number cannot begin 987. Let's next try 986. The best possible outcome would be for the number to begin 9867; can it?

Well, the same reasoning from a couple of paragraphs ago indicates that the remaining digits must then be 123 in some order. Again, they must form a multiple of 8. Even says xx2, and of these only 312 is a multiple of 8. So if the number begins 986 then the biggest it could possibly be is 9867312. And we can readily check that this is a multiple of all its digits, and then we're done.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.