# Multiples of a number permute the digits; find such a number

There is a $n$ digit number $N$ with all distinct digits and none of them being $0$. If we multiply $N$ by $1,2,3,4 \cdots n$, we get a number which has a permutation of the digits of $N$. But if we multiply $N$ by $(n+1)$, we get all $9$'s. How to find this $N$?

The solution/hint given is :

we can find $n+1=7 \Rightarrow n=6$ so the number $N$ is $142857$.

Could anybody help me in understanding this?

This problem is actually very simmilar to this $PE-52$:

It can be seen that the number, $125874$, and its double, $251748$, contain exactly the same digits, but in a different order.

Find the smallest positive integer, $x$, such that $2x, 3x, 4x, 5x,$ and $6x,$ contain the same digits.

I don't remember solving this just by remembering the property of this particular number, I think I had devised some kind brute-force search which gave me the answer, anyways it seems like there is a perfectly mathematical approach to deduce this number?!

• I didn't get the solution/hint either, but one thing I immediately thought of was $1/7$ and multiplying that fraction by $1, 2, \ldots$. – Shayla Nov 13 '11 at 0:34
• @Shayla:Oh yeah I knew this from an old PE problem but this hint make me believing that there is a perfectly mathematical approach to deduce this number. – Quixotic Nov 13 '11 at 0:50
• If you remove the restriction that 0 does not appear then you get the primes that has 10 as a primitive root. See oeis.org/A001913. – lhf Nov 13 '11 at 0:51
• If you have to ask, you'll never know.If you know, you need only ask. Let me add: if you ask and you get satisfactory answers, you accept one. – Did Dec 16 '11 at 22:36
• @Didier Piau: Indeed :D – Quixotic Dec 17 '11 at 6:31

If $n+1$ was $3$ or $9$, $N$ would be all $3$s or all $1$s, but the digits of $N$ are different hence this ain't so. If $n+1$ was even, the result would end with an even digit but the result ends with a $9$ hence this ain't so. If $n+1$ was $5$, the result would end with a $0$ or a $5$ but the result ends with a $9$ hence this ain't so. Since $n$ is the number of digits of $N$ which has distinct nonzero digits, $1\leqslant n\leqslant9$. Hence $2\leqslant n+1\leqslant10$ and the only remaining possibility is $n+1=7$. Thus, $7\cdot N$ is $999,999$ or $9,999,999$ but only the former is a multiple of $7$ hence $N=999,999\div7=142,857$.
If you cannot repeat digits and cannot use $0$, then $n\le9$. The all-nines condition says that $10^{n+1}-1$ is a multiple of $n+1$. In particular, $10$ and $n+1$ are coprime. So $n+1=1,3,7,9$. Just try them.
Clearly $n+1$ is at least $2$. Clearly no number of the form $99\dots9$ is a multiple of any even number, so $n+1$ must be odd. It clearly can’t be $3$ or $9$, since $33$ and $11111111$ repeat digits, and it can’t be $5$, because no number of the form $99\dots9$ is a multiple of $5$. The only possibility is therefore $7$. This explains the hint.
Even if one isn’t familiar with the properties of the decimal expansion of $1/7$, it’s easy enough to check that $n=6$ works.
Start dividing $999\dots$ by $7$: you get successively $1$ with a remainder of $2999\dots$, $14$ with a remainder of $1999\dots$, $142$ with a remainder of $5999\dots$, $1428$ with a remainder of $3999\dots$, $14285$ with a remainder of $4999\dots$, and $142857$ with a remainder of $999\dots$ $-$ or of $0$, if you choose to stop there. Since you have $7-1=6$ distinct digits, you stop and verify that multiplying $142857$ be $1,2,3,4,5$ and $6$ yields the desired result.