Given dividend and divisor, get the length of repeating digits in other bases than $10$ Inspired by this question, I was intrigued to ask how the length of the repeating and non-repeating digits can be calculated for bases other than $10$. For instance, if we have the fraction
$$
\frac{47}{16} = 2.9375,
$$
while not repeating in base $10$, it is repeating in base $9$:
$$
\frac{47}{16} = 2.83838383\ldots_9.
$$
It is obvious that it is repeating because of the presence of $8$ in the denominator, but how to we use this information to find the length of the non-repeating part (which is $1$) and the repeating part (which is $2$)? 
 A: To find the length of the non-repeating part, factor the denominator.  Find all the primes that are common between the denominator and $b$.  The length of the non-repeating part will be the power of $b$ needed to account for all the factors.  For example, if the denominator is $60=2^2\cdot 3 \cdot 5$ the non-repeating part in base $10$ will be of length $2$ because of the power of $2$ in the denominator.  The non-repeating part in base $9$ will have length $1$ to cover the $3$.  
To find the length of the repeating part, if the fraction is $\frac cd$ you can form products $cb^k \pmod d$.  When you get back to $c$ you have the length of the repeating part.  It will be a factor of $\phi(d)$, where $\phi$ is Euler's totient function.  
As an example, consider $\frac 1{52}$ in base $10$.  The two factors of $2$ in $52$ says there will be two non-repeating digits.  We will clear those factors, so the length of the repeat will be a factor of $\phi(13)=12$.  In fact, the repeat is $6$.  We get $\frac 1{52}=0.01\overline{923076}$
