# In a fraction between integers, what denominators produce a periodic result?

I'm trying to remember something that a math teacher told me many years ago about fractions. If I remember correctly he said that, in a fraction between integers, when the denominator is a multiple of $3$ or $7$, the result is a periodic number. Is this true? Are $3$ and $7$ the only numbers that produce periodic results? Bonus points for references and formal proofs. Thanks in advance.

Edit: Some examples:

$\frac{1}{4} = 0.25$, the result is not periodic

$\frac{1}{3} = 0.33\hat{3}$, the result is periodic

Edit 2: periodic in the sense of non-trivial infinite decimals. Hope this helps to understand what I mean. Probably periodic is not the best word.

• Every ratio has periodic decimals, if that's what you're asking. Dec 12 '12 at 18:18
• Actually, $\frac{1}{4}$ is ultimately periodic, it is $0.250000\dots$, or if you prefer, $0.249999\dots$. Dec 12 '12 at 18:28
• Every rational is eventually periodic if we allow periods consisting only of $0$s. You see that because when doing a long division $a:b$, there can only be remainders $0,\ldots b-1$, hence one of them must repeat sooner or later (after at most $b+1$ steps) and from then on the resuls are periodic. Try to find the period of $\frac1{19}$ for fun! Dec 12 '12 at 18:28

Assume your number base is $b>1$ and that you are given a rational number $r={p\over q}>0$ with $(p,q)=1$, meaning that $p$ and $q$ have no common divisors.

When long division $p:q$ performed in base $b$ finally ends with zero remainder this means that there is an $n\geq0$ and a certain natural number $k$ such that $${p\over q}={k\over b^n}$$ or $$p\ b^n=q\ k\ .$$ As $(p,q)=1$ the denominator $q$ of the given rational number $r$ has to be a divisor of $b^n$ for sufficiently large $n$, and this means that $q$ may contain any prime divisors present in $b$ to arbitrary multiplicity, but no prime divisors prime to $b$. When $b=10$ then $q$ has to be of the form $q=2^j\ 5^k$ with $j\geq0$, $\ k\geq0$.

When $q$ is not of this form then the long division $p:q$ cannot end after a certain number of steps. Now in dividing by $q$ there are only $q-1$ different remainders $\ne0$. It follows that after a finite number of steps in the long division we have to meet a remainder we have seen before, say: $\ell$ steps ago. The consequence is that the whole computation will repeat from then on after every $\ell$ steps, so that in the end our $b$-adic fraction representing the rational $r$ becomes periodic with period $\ell$ (or smaller).

In elementary number theory these things are discussed in detail. In particular one treats the question, for which $q$ the resulting period has maximal length $q-1$. For $b=10$ one such number is $q=7$.

• Brillant! Exactly what I needed. Thanks. Dec 12 '12 at 22:52

All rational numbers are periodic, but you seem to be interested in particular in those which cannot be written as terminating decimals like 0.25. Terminating decimals are rational numbers with denominators (in simplest form) which are a power of 2 times a power of 5. So $$\frac71 = \frac{7}{2^0\cdot5^0}$$ is a terminating decimal, as is $$\frac{9}{150}=\frac{3}{50}=\frac{3}{2^1\cdot5^2}$$ but not $$\frac{1}{150}=\frac{1}{2^1\cdot5^2\cdot3}.$$

Periodic is correct. Some decimals eventually become periodic: $\frac 16=0.16666\overline6$ There are leading non-periodic places if there are factors of $2$ or $5$ in the denominator. To prove it is periodic, we concentrate on primes greater than $5$. Note that $p$ divides $10^{p-1}-1$, so we can represent $\frac ap=\frac {k}{10^{p-1}-1}$ for some $k$, which will repeat with period $p-1$. It may repeat before that, always with a period that divides $p-1$.