How to create a polydivisible number of 10 digits by solving system of modulo equations?

61 Views Asked by At

A common puzzle, is to create a polydivisible number of 10 different digits (integers from 0 to 9). So the first two digits (from left to right) form a number that is divisible by 2, the first three digits makes a number that is divisible by 3 and so on.

My question is can this number be constructed without making multiples attempt? Making modulo equations and solving that?

Here is a partial solution (spoilers, try it yourself first)

  • The 10th digit is obviously a $%0$ so the whole number is divisible by $10$.
  • The 5th digit is divisible by 5, $0$ is not available so it must be 5
  • All the even number must be at even positions
  • Odd positions then contain odd numbers

And the rest of the solutions in the internet attempt multiple solutions at once and discard some solutions in the $n$-th place thanks to the division rule of $n$.

This is cumbersome, as nobody likes division by 7, one leaves it for last. Before using division-by-7 rule, you get 10 possible solutions that you have to try.

Question again

Is it possible to write the problem with the following equations and solve them using some algebra:

$$\left\{\begin{matrix} n_1,n_3,n_7,n_9\equiv 1 \pmod{2}\\ n_2,n_4,n_6,n_8\equiv 0\pmod{2}\\ n_1+n_2+n_3\equiv 0\pmod{3}\\ 10n_3+n_4\equiv 0\pmod{4}\\ n_5=5\\ n_4+n_5+n_6\equiv 0 \pmod{3}\\ \sum_{i=1}^7 n_i 10^{7-i}\equiv 0 \pmod{7}\\ 10n_7+n_8\equiv 0 \pmod{4}\\ 100n_6+10n_7+n_8\equiv 0 \pmod{8} \end{matrix}\right.$$

where $\{n_i\}\in\{1,2,3,4,5,6,7,8,9\}$, with $n_i\neq n_j$ for $i\neq j$.Breaking down the divisibility by 7 I can get: $$5n_2+4n_3+6n_4+3(1+n_6)+n_1+n_7\equiv 0 \pmod 7$$

Maybe I am missing something? Note that divisibility rule by 9 does not add anything.

Can this system of equations be solved analytically? Any theorem that could reduce it further?