Reciprocals of prime powers

Let p be a prime number. This post explores a relationship between the number of digits in the reciprocal of p and in the reciprocal of powers of p.

By the number of digits in a fraction we mean the period of the decimal representation as a repeating sequence. So, for example, we say there are 6 digits in 1/7 because

1/7 = 0.142857 142857 …

We will assume our prime p is not 2 or 5 so that 1/p is a repeating decimal.

If 1/p has r digits, is there a way to say how many digits 1/pa has? Indeed there is, and usually the answer is

r pa-1.

So, for example, we would expect 1/7² to have 6×7 digits, and 1/7³ to have 6×7² digits, which is the case.

As another example, consider

1/11 = 0.09 09 09 …

Since 1/11 has 2 digits, we’d expect 1/121 to have 22 digits, and it does.

You may be worried about the word “usually” above. When does the theorem not hold? For primes p less than 1000, the only exceptions are p = 3 and p = 487. In general, how do you know whether a given prime satisfies the theorem? I don’t know. I just ran across this, and my source [1] doesn’t cite any references. I haven’t thought about it much, but I suspect you could get to a proof starting from the theorem given here.

What if we’re not working in base 10? We’ll do a quick example in duodecimal using bc.

    $ bc -lq
    obase=12
    1/5
    .2497249724972497249

Here we fire up the Unix calculator bc and tell it to set the output base to 12. In base 12, the representation of 1/5 repeats after 4 figures: 0.2497 2497 ….

We expect 1/5² to repeat after 4×5 = 20 places, so let’s set the scale to 40 and see if that’s the case.

    scale = 40
    1/25
    .05915343A0B62A68781B05915343A0B62A6878

OK, it looks like it repeats, but we didn’t get 40 figures, only 38. Let’s try setting the scale larger so we can make sure the full cycle of figures repeats.

    scale=44
    1/25
    .05915343A0B62A68781B05915343A0B62A68781B0

That gives us 40 figures, and indeed the first 20 repeat in the second 20. But why did we have to set the scale to 44 to get 40 figures?

Because the scale sets the precision in base 10. Setting the scale to 40 does give us 40 decimal places, but fewer duodecimal figures. If we solve the equation

10x = 1240

we get x = 43.16… and so we round x up to 44. That tells us 44 decimal places will give us 40 duodecimal places.

Related posts

[1] Recreations in the Theory of Numbers by Alfred H. Beiler.

2 thoughts on “Reciprocals of prime powers

  1. 1/7 “has” 6 digits because the first power-of-ten-less-one that 7 divides is 999999. Similarly 11 divides 99 and that is why 1/11 has only 2 digits, et simile. But it is not obvious from this why 1/49 should have 42 digits, i.e. why the lowest (10^^n)-1 that 49 divides is (10^^42)-1 . What’s going on there?

  2. The first thing that came to mind was Euler’s theorem (which is related to Fermat’s Little Theorem in the linked post about periods of fractions).

    phi(7) = 6, which is why 10^6 – 1 divides 7; Euler’s theorem says 10^phi(7) = 1 (mod 7).

    And generally phi(p^k) = p^(k-1) * (p-1), so phi(7^2) = 7^1 * 6 = 42, so 10^42 = 1 (mod 49). The formula for the totient of prime powers seems to give us the recurrence we want.

    But it’s not the whole story, because phi(11) = 10, and technically 1/11 *is* periodic of 10 digits, but the minimum period is 2, not 10. So we need some kind of “reduced” totient with some factors taken out… but not Carmichael’s, something else. The case of 11 might make you think you can just take out any 2s or 5s you see, but that’s not it.

    Looking into one of the oddball numbers in the main post, phi(487) is of course 486. 486 = 2 * 3^5. The period of 1/487 is 27 = 3^3, less by a factor of 18.

    Gonna leave it for someone to pick up from there.

Leave a Reply

Your email address will not be published. Required fields are marked *