8

I've noticed that the reciprocal of many prime numbers have a curious number of digits. For example. 1/7 has 6 repeating digits, 1/17 has 16 repeating digits, and 1/47 has 46. There's a rule here that makes this pattern, and I haven't quite figured it out. Does anyone have some insight on this?

There are a few other numbers that follow the pattern subversively. For example, 1/3 has two repeating digits: 33. 1/11 has ten repeating digits: 0909090909. The number 1/13 has a set of six that repeats twice, which makes a set that's 12 digits long.

For reference, here is a website that lists reciprocals of numbers 2 through 70, including non-primes. https://thestarman.pcministry.com/math/rec/RepeatDec.htm

The ones that break the rule are 1/2 and 1/5, but they seem to be a matched pair, where the 2 and 5 switch places in the equation 1/X = Y/10

What is the rule that makes this pattern? I'm very curious.

J. W. Tanner
  • 60,406
kpres
  • 111

3 Answers3

5

Actually, in the case of $\frac13$, you have one repeating digit: $3$.

And the rule is: if $p$ is a prime number other than $2$ and $5$, then the period of the digital expansion of $\frac1p$ divides $p-1$. For instance, when $p=13$, the period is $6$ (as you wrote) and $6\mid 12$. But it could not be, say, $5$ or $8$.

And why $2$ and $5$ are exceptions? Because we work in base $10$ and $2$ and $5$ are the prime factors of $10$.

  • 3
    Well but why is that the rule though? – Mike Feb 13 '20 at 19:35
  • 2
    It might be instructive to explain why this rule holds. – Cheerful Parsnip Feb 13 '20 at 19:36
  • 1
    @Mike You will find a proof here. – José Carlos Santos Feb 13 '20 at 19:43
  • 1
    The point is that by Fermat's "little" theorem, if $p$ is a prime other than $2$ or $5$ we have $10^{p-1} \equiv 1 \mod p$. – Robert Israel Feb 13 '20 at 19:51
  • 1
    After reading up on Fermat's Little Principle, I now understand that $(10^(p-1)-1)/p$ will be an integer. That's great, because that integer is the exact sequence of digits that repeats, and the integer is $p-1$ digits long. F's LP doesn't predict that in the case of $1/3$, there is one repeating digit, or in the case of $1/11$, there are two. This formula gives 33 and 909090909 respectively. – kpres Feb 14 '20 at 01:03
  • @kpres: Yes, $(10^{p-1}-1)/p$ is always an integer for prime $p\ne2,5$. For some $p$ (e.g., $3,11,$ and $13$), $(10^d-1)/p$ is an integer when $d$ is a proper factor of $p-1$ (i.e., a factor of $p-1$ that is less than $p-1$) – J. W. Tanner Feb 14 '20 at 04:35
5

This is a consequence of Fermat's little theorem,

according to which $p$ divides $10^{p-1}-1$ if $p$ is not a factor of $10$ (i.e., $2$ or $5$).

If you picture the long division for $\dfrac 1p$, since the remainder after division of $10^{p-1}$ by $p$ is $1$,

the cycle of digits in the quotient repeats after ${p-1}$ digits.

J. W. Tanner
  • 60,406
1

Let $q$ be a prime s.t. $(q,10)=1$ and let $\ell$ be a period of $\frac{10}{q}$ ; i.e., the $j$-th and the $j+\ell$-th digit of $\frac{10}{q}$ are the same for all positive integers $j$. Then observe that $q|(10^{\ell+1}-10)$, which implies that $10^{\ell} \equiv_q 1$. Can you finish from here.

Mike
  • 20,434
  • I'm sorry, I'm having trouble understanding the syntax you are using. I think you are explaining how to predict the length of the period. Based on what you wrote, I notice that when I use $L=2$ and then put it into the formula $(10^(L+1)-10)/p$, only the prime reciprocals of length 2 will be integers; that is, 3 and 11. This is a great clue. Thank you for this insight! – kpres Feb 14 '20 at 18:03