TITLE: Why multiplication of 142857 with 2,3,4,5,6 gives the same digits shifted?
QUESTION [5 upvotes]: I was reading about a not so practical way to determine the divisibility of a number by $7$.
At some point the following number is mentioned: $142857$ (which is the result of $\frac{999999}{7}$) and apparently this number as I have verified if multiplied by $2,3,4,5, 6$ it gives the same digits in different order e.g. $142857 \cdot 3 = 428571$
Why does this number have this property? I see that the numbers $2,3,4,5,6$ are all remainders if we divide $100, 10, 10000, 100000, 1000$ by $7$ respectively but I am not sure if there is any correlation with the property.
I'd like to understand the intuition behind this "trick"
Note: I have found a similar post but I don't see any explanation on this

REPLY [3 votes]: Good question!
Let's see if we can noodle it out.
$\frac {1,000,000 -1}7 = 142857$.
And $2\times \frac {1,000,000 -1}7 = $ what... now you point out that $100 = 7k + 2$ where $7 =14$ so $2 = 100-7k$
$2\times \frac {100,000 - 1}7= (100-7k)\frac {1,000,000-1}7 =$
$100\frac {1,000,000 - 1}7 - k(1,000,000 -1) =$
$14,285,700 - \overline{k000000} +k$.
Hmm.... that we know $k = 14$ seems to be a really nice coincidence.
$14,285,700 - 14,000,000 + 14 = 285714$ and of course the numbers are reversed.
If we can assume that if $10^{m_j} = (\text{first }m_j\text{ digits of }142857)\times 7 + j$ for $j=2,3,4,5,6$ we'd be done.
After all we'd then have
$j \times 142,857=$
$(10^{m_j} -  (\text{first }m_j\text{ digits of }142857)7)\frac {1,000,000-1}7 =$
$10^{m-j}142,857 - (\text{first }m_j\text{ digits of }142857)7)1,000,000 + (\text{first }m_j\text{ digits of }142857)7)= $
$[\overline{(\text{first }m_j\text{ digits of }142857)(\text{last }6-m_j\text{ digits of }142857)\underbrace{0...0}_{m-j}}]- [\overline{(\text{first }m_j\text{ digits of }142857)000000}]+(\text{first }m_j\text{ digits of }142857)=$
$\overline{(\text{last }6-m_j\text{ digits of }142857)(\text{first }m_j\text{ digits of }142857)}$
......
So how can we show that for all $m_j \le 6 $ that $10^{m_j} = (\text{first }m_j\text{ digits of }142857)\times 7 + j$
Well.....
we know that $\frac {1,000,000 -1}7 = 142,857$.
This means $\frac 17= \frac 1{1000000}\frac {1000000}7 = \frac 1{1000000}[142,857 + \frac 17]$.  That means $\frac 17 = 0.142857\overline{142,857}$.
Okay....
So if we multiply $\frac 17$ times $10^{m_j}$ we get $10^{m_j}\frac 17 = (\text{first }m_j\text{ digits of }142857) + (\text{some decimal part less than } 1)$.
So $10^{m_j} = 7 \times (\text{first }m_j\text{ digits of }142857) + 7\times(\text{some decimal part less than } 1)=$
$7 \times (\text{first }m_j\text{ digits of }142857) + (\text{some value less than } 7)$
but as $10^{m_j}$ is a natural number (not divisible by $7$) we have
$10^{m_j} =  7 \times (\text{first }m_j\text{ digits of }142857) +j$ for some $1 \le j \le 7$
And that's it.
This will actually be true of any $n$ so that $\gcd(n,10) = 1$
Take, say $\frac 1{17}= 0.\overline{0588235294117647}$
We should get $0588235294117647 \times 2..... 16$ should be the same digits shifted.  Try it.