# length of 'digital' recurring expansion of rational number

Here's a question of a 'recreational' nature.

A similar question has already been posed for radix 10 in particular: Integer division: the length of the repetitive sequence after the decimal point . My question has been partly answered there; however, I'd be interested in anything further that can be added.

Suppose you have a rational number $n/d$ in simplest terms and a radix $r \ge 2$. Are there any results on the cycle length $l$ of the recurring part, and less importantly on the length of the prefix (numerals between the decimal point and the start of the recurring section)?

One result is that $l|d-1$.

I wonder whether there are simple results for various cases:

• $r$ is a prime $p$ (such as $2$)
• $r$ is a prime power $p^k$ (such as $16=2^4$)
• $r$ is square-free (such as $10 = 2 \cdot 5$), i.e. $r$ is a product of distinct primes, i.e $p^2|r$ for no prime $p$
• l divides the totient of d, which doesn't necessarily divide d-1. In any case, the form of r is irrelevant, since the answer only depends on the value of r mod d. – Qiaochu Yuan Aug 16 '10 at 23:16

Write $d=2^p 5^q m$, where $(m,10)=1$. Then the length of the prefix of $n/d$ is $\max(p,q)$. (That's for base 10, of course.)