Repeating decimals linked to reciprocals of primes Now this question is base dependent, I will assume base 10 but feel free to generalize.
I was noticing that for small primes that are not factors of the base ($2$ and $5$ terminate) the reciprocal of the prime (read $\frac 1p$) was a repeating decimal. 
Will the reciprocal of any prime other than the two mentioned form a repeating decimal?
Is there anything you can say about the order of the repeating decimal if you know the prime that generated it?
 A: In fact, if $p$ is a prime greater than $5$ (this excludes both primes $2$ and $5$ and also $3$), the decimal expansion of $1/p$ is periodic with period length equals $e=\operatorname{ord}_p(10)$ the order of $10$ modulo $p$, i.e., $e$ is the smallest positive integer such that $$10^e\equiv 1 \pmod p$$
This result can be generalizated in any number base $B>1$ and extended to any fraction $x/n$ where the numerator $x\in \mathbb{U}_n$, the set of positive integers less than and relatively primes to $n$ and $\gcd(B,n)=1$. With this hypothesis, the decimal expansion of $x/n$ in the base $B$ is periodic and its period length is the order of $B$ modulo $n$ (which exists because of the relatively prime condition between $B$ and $n$). Note that the period length of $x/n$ don't depend of $x$, so each one of the fraction $x/n$ always have the same period length.
A: Given a prime $p \neq 2,5$, it is always the case that $1/p$ has a repeating decimal expansion.

Lemma: Every prime $p \neq 2, 5$ divides a repunit.
Proof of Lemma:
Fix a prime $p \neq 2,5$. Let $\textbf{A}$ be the set of repunits, so
$$\textbf{A} = \left\{\displaystyle\sum\limits_{k=1}^{n} 10^{k-1} \, \mid \, n \in \mathbb{N} \right\} = \left\{\frac{10^n -1}{9} \, \mid \, n \in \mathbb{N} \right\}$$
Consider the repunits, modulo $p$. Since $\mathbb{N}$ is not a finite set, neither is $\textbf{A}$. There are a finite number of remainders modulo $p$ (specifically, $p$ possible remainders). 
There are (infinitely) more repunits than remainders modulo $p$. Thus, there must exist two distinct repunits with the same residue modulo $p$. So $$ \exists \, a, b \in \textbf{A} \,\, \text{s.t.} \,\,\,\,\,\, a \equiv b \pmod{p}, \,\, a \neq b$$
Without loss of generality, assume $a > b$. 
Since $a, b \in \textbf{A}$, $\exists \, x, y \in \mathbb{N}$ with $x > y$ such that
$$a = \frac{10^x - 1}{9}$$
$$b = \frac{10^y - 1}{9}$$
We can substitute in to $a \equiv b \pmod{p}$ to get:
$$\frac{10^x - 1}{9} \equiv \frac{10^y - 1}{9} \pmod{p}$$
$$\frac{\left(10^x - 1\right)-\left( 10^y - 1\right)}{9}\equiv 0 \pmod{p}$$
$$\frac{10^x-10^y}{9} \equiv 0 \pmod{p}$$
$$\frac{\left(10^y\right)\left(10^{x-y}-1 \right)}{9}\equiv 0 \pmod{p}$$
We know that $p \nmid 10^y$, because $p$ is not $2$ or $5$. Since $\mathbb{Z}/p\,\mathbb{Z}$, the ring of integers modulo $p$, has no zero divisors (because $p$ is prime), 
$$\frac{10^{x-y}-1}{9}\equiv 0 \pmod{p}$$
This is a repunit. 

Since our choice of $p \neq 2, 5$ was arbitrary, we have proved that every prime that is not $2$ or $5$ divides a repunit. It follows that every prime that is not $2$ or $5$ divides nine times a repunit (a positive integer whose digits are all nines). 
This means that for every $p$ that is not $2$ or $5$, there exist positive integers $m$ and $n$ such that such that
$$\frac{1}{p} = \frac{m}{10^{n}-1}$$
Since $m$ is not equal to $10^n -1$, this implies that $1/p$ has a repeating decimal representation, and further that the period of repetition divides $n$. 
