Computing reciprocals of primes I was looking at the following video :
https://www.youtube.com/watch?v=DmfxIhmGPP4
where I learnt that William Shanks was trying to compute the reciprocals of prime numbers and see after how many terms in the decimal place, it started repeating. For e.g. $1/11=0.090909...$ and it repeats after $2$ decimal places. In order to compute this for any prime $p$, one may create the multiplication table of $p$ and then keep dividing until repetition occurs.
However in the YouTube link, it was mentioned that Shanks probably was doing it using some other technique since all his errors were either his answer being double or half the original answer. Naturally I started wondering how one may go about doing it in order to make it easier and couldn't come up with anything fancy. Does anyone know what he actually did? Any other novel ideas will also make me happy.
 A: Well, I'm not sure if this helps, but the number of digits in the repeating expansion of $p$ is simply the smallest number $k$ such that the repeating number $999\ldots 99$ where there are $k$ $9$'s is divisible by $p$.
For instance in the case of $1/11$ we see that there are two repeating digits because $11\mid 99$. Note that the repeating number can also be represented as $10^k-1$, so we want $p\mid 10^k-1$, or $10^k\equiv 1$ (mod $p$). Now it is clear that the number $k$ we are looking for is simply order base $p$ of $10$, or ord$_p(10)$. Keep in mind that by Fermat's Little Theorem, $k$ has to divide $p-1$. Like in the case of $11$, where $2\mid 11-1=10$. So, we only have to look through the factors of $p-1$ to find our answer.
Here is an example of finding it for the number $59$:
So $59-1=58$, so we only need to look at $1, 2, 29$, and $58$. $10^1$ and $10^2$ clearly don't work, so we only need to figure out if $10^{29}$ works. $10^3=1000=56=-3$ and $10^{27}=(-3)^9=-19683=23$. And $23*100=-1$. So $10^{29}$ is $-1$ in mod $59$, meaning it doesn't work, so we know $1/59$ has $58$ repeating digits.
