The length of the repetend of the reciprocal of a prime number \(p\) in any number base \(b\), such that
\(b\) is not multiple of \(p\), will always divide \(p-1\).
Over the course of this page, you will learn what that actually means, how to prove it, and why that's a slightly
useful property.
In decimal, one seventh is written 0.142857. (By the way, over the course of this page,
overlines mean repetends.) This repetend is 10 (6) symbols long. What my theorem says
is that this length can only be 1, 2, 3 or 10 (6), as those divide 11-1 (7-1=6).
This can be shown in the extensions of one over seven in various bases:
Like predicted, no 1② (4) or 1① (5)-long repetends.
Here's a bigger table (in decimal for ease of generation and reading) with the first ten primes and bases up to
1①① (29) to show extensively the point:
Base
2
3
5
7
11
13
17
19
23
29
B
0
2
4
3
10
12
8
18
11
28
T
1
0
4
6
5
3
16
18
11
28
Q
0
1
2
3
5
6
4
9
11
14
P
1
2
0
6
5
4
16
9
22
14
H
0
0
1
2
10
12
16
9
11
14
S
1
1
4
0
10
12
16
3
22
7
O
0
2
4
1
10
4
8
6
11
28
E
1
0
2
3
5
3
8
9
11
14
D
0
1
0
6
2
6
16
18
22
28
UD
1
2
1
3
0
12
16
3
22
28
Z
0
0
4
6
1
2
16
6
11
4
UZ
1
1
4
2
10
0
4
18
11
14
BS
0
2
2
0
5
1
16
18
22
28
TP
1
0
0
1
5
12
8
18
22
28
X
0
1
1
3
5
3
2
9
11
7
UX
1
2
4
6
10
6
0
9
22
4
TH
0
0
4
3
10
4
1
2
11
28
UTH
1
1
2
6
10
12
8
0
22
28
V
0
2
0
2
5
12
16
1
22
7
TS
1
0
1
0
2
4
4
18
22
28
BUD
0
1
4
1
0
3
16
18
2
14
UBUD
1
2
4
3
1
6
16
9
0
7
QH
0
0
2
6
10
12
16
9
1
7
PP
1
1
0
3
5
2
8
9
11
7
BUZ
0
2
1
6
5
0
8
3
11
28
TE
1
0
4
2
5
1
16
6
11
28
QS
0
1
4
0
10
12
16
9
22
2
UQS
1
2
2
1
10
3
16
18
11
0
As you can see, all of the numbers follow the pattern! This is enough to conjecture my initial statement, but how
do we go about proving it?
The way you find the length of the reciprocal of the prime \(p\) in the base \(b\) can be given by the smallest
\(l\) that satisfies the following:
\[\dfrac{1}{p} = \dfrac{a}{b^l - 1}\] given that \[a, l \in \mathbb{N}, \gcd(b, p) = 1 \]
This can be proven by the following logic:
Imagine a number \(\frac{1}{p} = x\) of the form \(0.\overline{a}\), where \(a\) is the \(l\)-digit long
extension.
\begin{align}
x &= 0.\overline{a}\\
b^l x &= a.\overline{a}\\
b^l x - x &= a.\overline{a} - 0.\overline{a}\\
(b^l - 1)x &= a\\
x &= \dfrac{a}{b^l - 1}\\
\dfrac{1}{p} &= \dfrac{a}{b^l - 1}
\end{align}
Now, this isn't a very easy formula to work with. Especially with the pesky \(a\) hanging on. However, we can get
rid of it with a little rearranging and modular arithmetic:
\[ b^l-1 = a \cdot p \]
\(a\) must be an integer, so \(b^l-1\) must be a multiple of \(p\).
\[ b^l-1 \equiv 0 \pmod p \]
\[ b^l \equiv 1 \pmod p \]
This means that to find out what \(l\) is, we can simply raise \(b\) to consecutive powers until it becomes
equivalent to 1. If you know Fermat's little theorem, you know where this goes next!
By Fermat's theorem, we can guarantee that \( b^{p-1} \equiv 1 \pmod p \). If you don't know Fermat's little
theorem, here's a lot of proofs. I
originally had a whole writeup attempting to explain the group theory proof, but it felt rather confusing and
redundant.
Armed with this result, we can prove that \(kl = p-1\) for some \(k \in \mathbb{N}\) by contradiction:
Assume \(p-1\) is not a multiple of \(l\). Then \(p-1 = kl + m\), for some \(m \in \mathbb{N}, l \gt m \ge 1\).
If \(b^l \equiv 1 \pmod p\) and \(b^{p-1} \equiv 1 \pmod p\), then:
Therefore \(l\) is not the smallest \(x > 0\) such that \(b^x \equiv 1 \pmod p\), which contradicts the original
setup. QED.
This is an extremely niche property, but it is kind of useful when you are comparing number bases. Instead of
looking through every possible denominator to find the size of a reciprocal, you can simply check the divisors of
\(p-1\) to speed up the search!
This also showcases a few interesting things about the length of extensions:
Every base can write the reciprocal of a prime number one below itself with a single repeating digit: \[b = p+1
\implies b^1 \equiv 1 \pmod p \implies l = 1\]
Every base can write the reciprocal of the number one above itself with two repeating digits: \[b = p-1 \implies
b^1 \equiv -1 \pmod p \implies b^2 \equiv 1 \implies l = 2\]
The maximum length of a reciprocal is the prime minus 1 (yes, everyone already knows that, but it is important to
reiterate);
And lastly, every even-length repetend of a prime reciprocal can be written in the double overlined form in a balanced base:
If \((b^n - 1) \equiv 0 \pmod p\), \(b^n \equiv 1 \pmod p\), so \(l\) isn't the smallest possible value, which is
a contradiction;
And if \((b^n + 1) \equiv 0 \pmod p\), \(b^n \equiv -1 \pmod p\), so the remainder after \(n = \frac{l}{2}\)
fractional places will be -1, and remember that, when you hit -1, you are doomed to repeat the path you just took
but with flipped signs.
...
Okay I don't really know where I was going with this but. It sounds smart, right?