# Predicting the number of decimal digits needed to express a rational number

The number $1/6$ can be expressed with only two digits (and a repeat sign denoted as $^\overline{}$), $$\frac{1}{6} = \,.1\overline{6}$$ Meanwhile, it takes 49 digits to express the number $1/221$, since a string of 49 digits repeats: $$\frac{1}{221} = .\overline{004524886877828054298642533936651583710407239819}$$ Yet for $1/223$, 222 digits repeat, giving a total of 224 digits needed to express the number.

If $f:\mathbb{Q}\rightarrow\mathbb{N}$ is a function that gives the smallest number of digits needed to express a rational number in decimal notation, what can we say about $f$?

For example, if we do not consider the negative sign to be a digit, then $f$ is an odd function. Other than that, is there any pattern to it at all?

-
223 is prime ;-) –  dtldarek Jul 22 '13 at 12:54
@Cocopuffs thanks! I was duped by the first recurrence of "425". Corrected. –  Doubt Jul 22 '13 at 13:04
Typo in "... digits to express ... 1/121, ...": it should be "... 1/221, ...". –  John Bentin Jul 22 '13 at 13:27
This related link may be useful. –  user64494 Jul 22 '13 at 14:25
$233$ is prime and $1/223$ may have a $222$-digit repetend, but one should not make the mistake of thinking the shortest repetend of $1/p$ is always $p-1$ when $p$ is prime. For example, the length of the shortest repenend of $1/3$ is $1$; for $1/11$ it is $2$; for $1/37$ it is $3$; for $101$ it is $4$; for $41$ it is $5$; and for $13$ it is $6$. ${}\qquad{}$ –  Michael Hardy Jun 11 at 18:36

Consider the fraction $1/m$. Write $m=2^a 5^b v$ with $\gcd(v,10)=1$. Then the periodic part of $1/m$ has length $e$, where $e$ is the smallest positive number such that $v$ divides $10^e-1$. The non-repeating part has length $f=\max(a,b)$.

There are no easy formulas for either $e$ or $f$ in terms of $m$.

-
We can, of course, say some things about $e$. For example, $e|\phi(v)$ which gives us an upper bound. –  Thomas Andrews Jul 22 '13 at 13:26
@ThomasAndrews, we can use Carmichael's $\lambda$ instead of Euler's $\phi$ and usually get much better bounds, but both functions are hard to compute when $v$ is not prime. –  lhf Jul 22 '13 at 14:06