# What is the longest terminating (or repeating) decimal created by the division of two natural numbers in which neither number is more than two digits?

I came across a problem today while teaching in which a long division problem created an unusually long terminating decimal. It intrigued me into more thinking on this.

My question is: What is the longest terminating (or repeating) decimal created by the division of two natural numbers in which neither number is more than two digits? And, is there a way to prove this besides using brute force in trying all possibilities?

• Since we can't repeat until we hit the same remainder, it's feasible that the more remainders are possible, the longer we can go before repeating. I'd try large two digit primes (not sure why prime, but I have $1/7$ in mind) for the denominator, like 97. – pjs36 Jan 5 '17 at 5:02
• See here also: en.m.wikipedia.org/wiki/Repeating_decimal – user371838 Jan 5 '17 at 5:09

The number of digits in the repeat of $\frac 1n$ (larger numerators can only decrease the number of digits) is always a factor of $\phi (n)$, Euler's totient function, the number of numbers less than and coprime to $n$. For primes, $\phi(n)=n-1$, so pjs36's intuition to try large primes is a good one. Once we discover $\frac 1{97}$ has a repeat of $96$ digits, we only need to find that $\phi(98)=42$ and $\phi(99)=60$ and we are done. In fact, the repeat of $\frac 1{98}$ is $42$ decimals, but $\frac 1{99}=0.\overline{01}$
• @GerryMyerson: true, but it can have an effect on the period length if it were not prime. I wanted to claim that for $98$ and $99$ as well I could just look at $\frac 1{98}$ and $\frac 1{99}$ even though they are not prime. – Ross Millikan Jan 5 '17 at 6:16
• @RossMillikan OK, that makes sense. So would the same be applied to 3 digit numbers? Would $\frac{1}{997}$ be the largest repeating decimal created by two natural numbers no more than 3 digits? – MathGuy Jan 5 '17 at 14:09
• No, because the period of $1/997$ is $166$, not $996$, so you should keep looking down the list of primes. What is going on is that the numbers coprime to $n$ form a multiplicative group. It may or may not be that $10$ is a generator of the whole group, which means you can represent all the elements as $10^k$. The first time this fails is $13$, where the powers of $10$ are $10,9,12,3,4,1$ and the period of $1/13$ is $6$, not $12$. – Ross Millikan Jan 5 '17 at 14:38