Imagine a number N which is made of digits d repeating n times
eg:
Row Number | N | N mod 7 |
---|---|---|
1 | 3 | 3 |
2 | 33 | 5 |
3 | 333 | 4 |
4 | 3333 | 1 |
5 | 33333 | 6 |
6 | 333333 | 0 |
7 | 3333333 | 3 |
8 | 33333333 | 5 |
9 | 333333333 | 4 |
10 | 3333333333 | 1 |
11 | 33333333333 | 6 |
From row 7 it keeps repeating
The reason i am asking this question due to this Problem
Is there any proof to this or is it just that I have to remember this.
It my first time encountering this pattern
$$$10^6 \equiv 1 \,\, \text{mod} \,7$$$ and $$$\frac{111111}{7} = 15873$$$.
$$$1111111 \equiv \,\, 1\cdot 10^6 + 111111 \equiv 1 + 111111\,\, \text{mod} \,7$$$
$$$11111111 \equiv \,\, 11 \cdot 10^6 + 111111 \equiv 11 + 111111\,\, \text{mod} \,7$$$
$$$11111111 \equiv \,\, 111 \cdot 10^6 + 111111 \equiv 111 + 111111\,\, \text{mod} \,7$$$
So we can spit number into blocks of $$$6$$$ and one block of $$$n \,\,\text{mod} \, 6$$$ ones (where $$$n$$$ number of digits), and all blocks of $$$6$$$ are divisible by $$$7$$$, so it repeats each $$$6$$$.
Note that, $$$\gcd(10, 7) = \gcd(9, 7) = 1$$$. Now, we have
By Fermet's Little Theorem we have,
Hence we'll get a repetition modulo 7.
think like d*(1111..n times), now after every 6 "1" the number would be divisible by 7, because 111111 is completely divisible by 7, so the number would be divisible by 7 if n is a multiple of 6.
See I have a proof
Cyclic Remainder of N Divisible by 7
Any number N=dddddd....d can be written as
N= ddddd....d = 11111....1*d
Now we break this number into k blocks of 6 numbers each and one block with x number
N = dddddd*10^(6(k-1)+x) + dddddd*10^(6(k-2)+x) + .... + dddddd + dd..d (x times,x<6).
And there's a fact that dddddd%7==0. d can be any(1-9).
as dddddd=111111*d , and 111111%7==0 So from the above equation we can see that
N%7 =dd..d (only x times)
This suggests that the remainder we get will repeat in cycles of 6(the d=7 case is obvious ig)
*(Sorry for the wrong alignment, I am new that's why I don't have much idea)
let's say the number is $$$n$$$
then adding the next digit, the number would be $$$10n+d$$$
if $$$n \equiv k \space (mod \space p)$$$ then the next modulo would be $$$10k+d \space (mod \space p)$$$
one way to visualize this is with a graph with an directed edge between node $$$k$$$ and node $$$10k+d \space (mod \space p)$$$
if $$$p$$$ is coprime to $$$10$$$, then the following graph would have $$$p$$$ nodes, $$$p$$$ edges and will contain multiple components, each of them containing a cycle and some paths leading to a cycle (since there are no unique a,b that maps to the same node)
if there are:
$$$10a+d \equiv 10b+d \space (mod \space p)$$$
$$$10a \equiv 10b \space (mod \space p)$$$
since $$$p$$$ and $$$10$$$ are coprime:
$$$a \equiv b \space (mod \space p)$$$
if $$$p$$$ and $$$10$$$ aren't coprime then
$$$10k+d \equiv d \space (mod \space p)$$$ which means every edge will connect to d, which will make it a single cycle of size 1
this could also be extended to ANY base/digit and modulo
One of the ways to solve this problem is compute $$$10^x \, mod \, p$$$ for example for $$$p = 7$$$ the sequence of the answers of this expression is:
$$$[1, 3, 2, 6, 4, 5]$$$ (sequence of answers is a periodic with this period)
so $$$6$$$ should count $$$n!$$$
it means $$$3 \le n$$$