# Period of repeating decimals

Note: This question is base sensitive. Therefore, assume we have fixed a base $b$. By abuse of terminology, I will still use the word "decimal".

This question revolves around the period of repeating decimals. For an integer $i$, define $f(i)$ as the period of the expansion of $i^{-1}$, or $1$ if the decimal expansion of $i^{-1}$ terminates. As an example, $f(3) = 1$ or $2$, depending on $b$.

Now, the behaviour of $f$ is a delightful mix of pattern and chaos. I (think I) have found three things so far:

1) For any natural $i$, $f(i) \leq (i-1)$.

2) If $i$ divides a number of the form $b^{n-1} + 1$ or $b^n - 1$ (for applicable $n$) then $f(i) \leq n$ (I believe this to be an equality if $n$ is minimal).

3) If $i = j_1\cdot j_2$ with $j_1$ and $j_2$ coprime, then $f(i) \leq \text{lcm}(f(j_1), f(j_2))$.

Now, what I want to know is whether or not these three points are correct, and whether or not the upper bound of $f(i)$ given by these three points together is indeed the value.

-
Your point (2) can be formulated to say that if $(b, i) = 1$, then $f(i)$ divides $\varphi(i)$, where $\varphi$ is Euler's totient function. –  Andreas Caranti Feb 9 '13 at 20:15
@AndreasCaranti seems so, but that isn't as strict as the equality in point 2, granted that equality holds for minimal $n$. –  Arthur Feb 11 '13 at 21:38

By period, I assume you mean minimal period, otherwise there are inifinitely many periods.

Write $i=x_iy_i$, where every prime factor of $x_i$ divides $b$, and $\gcd(y_i, b)=1$. Then $f(i)=f(y_i)=ord_{y_i}(b)$, where $ord_{y_i}(b)$ is the multiplicative order of $b \pmod{y_i}$.

This is because:

$x_i$ does not affect the minimal period $f(i)$.

If $y_i \mid (b^n-1)$ for some $n$, then let $b^n-1=ky_i$, then $$\frac{1}{y_i}=\frac{k}{b^n-1}=\frac{k}{b^n(1-b^{-n})}=\frac{k}{b^{n}}+\frac{k}{b^{2n}}+ \ldots$$

So $\frac{1}{y_i}$ has $n$ as a period. Since the smallest such $n$ is given by $ord_{y_i}(b)$, $f(y_i) \leq ord_{y_i}(b)$.

On the other hand, since $f(i)$ is a period, let $l$ be the number representing the repeating string, so we can write $$\frac{1}{y_i}=\frac{l}{b^{f(i)}}+\frac{l}{b^{2f(i)}}+ \ldots=\frac{l}{b^{f(i)}(1-b^{-f(i)})}$$

Thus $b^{f(i)}-1=ly_i$, so $f(y_i) \geq ord_{y_i}(b)$.

1 is mostly correct, as we have $f(i)=f(y_i)=ord_{y_i}(b) \leq \varphi(y_i) \leq y_i-1 \leq i-1$ for $y_i>1$, and if $y_i=1$, $f(i)=1 \leq i-1$ for $i>1$. The only exception is $i=1$, as $f(i)=1>1-1$.
2 is partially correct. The $b^n-1$ part is correct, but not the $b^{n-1}$ part.
3 is correct. $y_i=y_{j_1}y_{j_2}$ so $f(i)=ord_{y_i}(b)=lcm(ord_{y_{j_1}}(b),ord_{y_{j_2}}(b))=lcm(f(j_1),f(j_2))$.
This does adress my concern about $i = b^n + 1$ too, as $b$ then has order $2n$, which is the length of the (yes, minimal) period of $i^{-1}$. I just didn't think very far when I wrote that point. –  Arthur Feb 12 '13 at 7:55