Friday, 8 December 2023

Periods of Prime Reciprocals

I've written about the periodic decimal representations of prime number reciprocals before, specifically in a post titled Cyclic Numbers on November 23rd 2019. All prime reciprocals are periodic with periods that are of the form:$$ \frac{p-1}{k} \text{ where } k=1, 2, 3, \dots $$What I'd never considered however, was the relative frequencies of these periods for different values of \(k\). It's not difficult to generate a table (permalink) to show this information. I've considered only primes in the range up to 40,000. See Figure 1.


Figure 1

As can be seen, more than a third of primes have reciprocal periods where \(k=1\). It's only when we reach \(k=31\) that we find no such primes in the range up to 40000. However, if we extend the range up to one million then there are 24 primes \(p\) with a period of \( (p-1)/31 \). These primes are (permalink):

49663, 113647, 129023, 136897, 160829, 163061, 381487, 437287, 462149, 501829, 503131, 591233, 675553, 697687, 699299, 701593, 770909, 791927, 800731, 860623, 863909, 918779, 933349, 969743

It would seem that for any arbitrary \(k\) there will be an infinite series of prime numbers \(p\) have a reciprocal period of \( (p-1)/k \). Sometimes the initial prime number is not all that large. Take \(k=101\) for example. In the range up to one million there are two primes with this property, namely 5051 and 637513. For \( k=197 \) there are three primes: 74861, 818339 and 931811.

For any composite number, the period of its reciprocal is the product of the periods of its prime factors divided by their greatest common divisor. For example:$$ \begin{align} 2077 &= 31 \times 67\\ \text{period} \Big ( \frac{1}{31} \Big ) &= 15 \\ \text{period}  \Big (\frac{1}{67} \Big )&= 33 \\ \text{gcd} (15,33) &=3 \\ \text{period} \Big ( \frac{1}{2077} \Big ) &= \frac{15 \times 33}{3} \\ &= \frac{495}{3} \\ &=165 \end{align}$$What's also of interest is a list of the first primes that are divisible by the various divisors once 1 is subtracted from them. The results are shown in Figure 2 over the range up to 100,000. Notice that there is no result for 41 in this range. Notice that for 2 and 5 a result of 1 is returned. This is because when \(n\) is composite, \(n\).period() returns the value 1 (permalink).


Figure 2

The first prime less 1 that is divisible by 41 is 118901 whose reciprocal has a period of 2900. Thus 41 holds the record for hosting the largest prime minus 1 divisible by numbers between 1 and 50.

No comments:

Post a Comment