Is it possible to write a nine-digit number such that its first digit is divisible by 1, its two first digits are divisible by 2, its three first digits by 3, and so on until the whole nine-digit number is divisible by 9?
Let's try to build such a number starting from left to right, digit by digit. Any number from 1 to 9 will make do to start, as every integer is divisible by 1. Let’s say the number three:
The second digit must be even to ensure that the entire number is divisible by 2. Let’s say 4. So, our number is now
Ok, do you remember the divisibility rule for 3? Sure, the sum of the digits has to be divisible by 3. The number
fulfills the rule (3+4+2=9), and so does the numbers 345 and 348. But let’s continue with 342. I like that number.
Divisibility rule by 4? The last two digits have to be divisible by 4. The number
is suitable as 28 is divisible by 4 (so the entire number is divisible by 4 too). If we add a digit 0 or 5 to the right we would have a number divisible by 5. As we are not using the digit 0 (remember, only from 1 to 9) the only option is
All right. Rule for 6? The number should be divisible by both 2 (so it ends in an even digit) and 3 (so their digits add up to a multiple of three). The number
will do (and also 342858, which is 6 units more... but I like more the former, for no reason).
We are on the right track. There are only three digits left! Let’s add another one that makes the number divisible by 7... Well, I have to confess that I don’t remember the divisibility rule for 7 (it’s a bit tough) but I do know how to divide. So, let me try my luck with the number 3428529 (I have put a 9 as a possible seventh digit). I take my pencil, divide 3428529 by 7 and… bad luck, the division is not exact: It gives a remainder of 6. But that’s the clue… if we subtract 6 units to the failed candidate 3428529, we get or certain a number divisible by 7:
Uff... it’s nearly finished. With the same trick applied to number 8 we can get next digit and write then
Finally, a number is divisible by 9 if its digits add up to a number that is divisible by 9 (yeah, I do remember the rule for 9!). Let me operate... 3+4+2+8+5+2+3+2=29... so we must add 7 as the final digit to allow the sum to be 36, which is a multiple of 9. Perfect, we are done! Our number is:
Wow, we did it!
Can you get other numbers with the same property? Sure you can as there are many more choices (concretely 2,492 altogether). These numbers are called polydivisible numbers.
But don’t relax yet... You know that mathematicians like imposing additional conditions to complicate things. For example, if each number from 1 to 9 is allowed to appear exactly once, is it now possible to build a polydivisible number with the nine digits? The answer is yes, but this time there is a unique solution: 381654729 (see references for a witty deduction… or try it by yourself)
And you also know that mathematicians love generalizing. So, we can consider polydivisible numbers with more than 9 digits. For instance, 10200056405 is a 12-digit polydivisible number (you can check it). Obviously numbers from 0 to 9 can be repeated. With many digits involved getting a polydivisible number becomes more and more difficult. Then, the burning question is: Are there infinitely many polydivisible numbers? And the answer is… nop. There are only 20,456 polydivisible numbers altogether, being the longest one:
3 608 528 850 368 400 786 036 725
In fact, this is the only 25-digit number that is polydivisible. Next graph shows the number of polydivisible numbers in terms of the number of digits… read again last sentence slower if needed ;-)
The density of n-digit polydivisibility numbers can be defined as the quotient between the number of polydivisible numbers with n digits and the total numbers with n digits (i.e. 10n). For 1-digit numbers the density is 1 (all numbers are polydivisible), while for 26-or-more-digit numbers the density is strictly zero (none is polydivisible). Have a look to the graph below.