Article 5Q3MY Reciprocals of prime powers

Reciprocals of prime powers

by
John
from John D. Cook on (#5Q3MY)

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^2 to have 6*7 digits, and 1/7^3 to have 6*7^2 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^2 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.

The post Reciprocals of prime powers first appeared on John D. Cook.ZnMWpP0Z4Pk
External Content
Source RSS or Atom Feed
Feed Location http://feeds.feedburner.com/TheEndeavour?format=xml
Feed Title John D. Cook
Feed Link https://www.johndcook.com/blog
Reply 0 comments