Prime Reciprocals Analysis


Prime Reciprocals Analysis

Maria
Corey, I've got something really interesting to talk about today. It involves a mathematician from the 1800s and some incredibly meticulous handwritten calculations.

Corey
Oh, that sounds fascinating! A handwritten mathematician from the 1800s? What kind of calculations are we talking about? Was he working on something famous?

Maria
Well, his name was William Shanks, and I think today we'd call him a recreational mathematician. He had a day job running a boarding school, but his passion was performing endless calculations in his spare time.

Corey
A recreational mathematician, I love that! So he wasn't doing this for a living, just for the sheer joy of it? What exactly was he calculating that required so much effort?

Maria
He was calculating the reciprocals of prime numbers. Specifically, he was trying to find out how many digits it would take for the decimal expansion of 1 divided by a prime number to start repeating.

Corey
That's a very specific niche! So like, 1/7 is 0.142857 and then it repeats. He was trying to find the length of that repeating part for huge prime numbers?

Maria
Exactly! He'd send his results to the Royal Society. We're talking about primes like 60,013, where he claimed the reciprocal would repeat after 5,001 digits. He did these in batches over many years.

Corey
Wow, 5,001 digits by hand! That's an astonishing amount of work. How could anyone even verify such a thing without modern computers?

Maria
Well, we can verify it now! I actually wrote a little Python script, my 'ShanksBot,' to do just that. If you give me a prime, we can check his work.

Corey
Okay, let's try 61,561. What does your ShanksBot say about that one? I'm curious to see if old William Shanks was accurate.

Maria
ShanksBot says 405 digits! And Shanks's notes agree, 405 digits. Isn't that incredible? Two different eras, same result.

Corey
That's amazing! It really highlights his dedication and skill. But how did he even do it? Can you walk me through an example, maybe with a smaller prime?

Maria
Sure, let's take the prime 7. We're calculating 1 divided by 7 using long division. You start by seeing how many times 7 goes into 1, which is zero, so you add a decimal and a zero, making it 10.

Corey
Right, so 7 goes into 10 once, with a remainder of 3. Then you bring down another zero, making it 30. This is the standard long division process.

Maria
Exactly. 7 goes into 30 four times, with a remainder of 2. Then 7 into 20 goes twice, remainder 6. 7 into 60 goes eight times, remainder 4. You keep going like this.

Corey
And you eventually get 7 into 40 five times, remainder 5, then 7 into 50 seven times, remainder 1. Oh, that 1 is what we started with!

Maria
Precisely! Once you hit that remainder of 1 again, the whole sequence of digits will repeat. So for 1/7, it's 0.142857, and that's six digits before it repeats.

Corey
So, it enters an infinite loop. That makes sense. Will all prime numbers eventually hit an infinite loop like this, or is it just some of them?

Maria
Yes, all primes will eventually hit a repeating loop. The reason is that with each step in the long division, your remainder must be a number smaller than the prime you're dividing by.

Corey
Ah, I see. So for prime 7, your remainders could only be 1, 2, 3, 4, 5, or 6. Once you get back to a remainder you've seen before, the pattern has to repeat because you're doing the same calculation again.

Maria
That's exactly it. Let's try a slightly larger prime, say 23, to illustrate. We're dividing 1 by 23. You start by finding multiples of 23.

Corey
Okay, so 23 times 1 is 23, times 2 is 46, times 3 is 69, and so on. This table would be crucial for Shanks to keep track of, especially with bigger primes.

Maria
Absolutely. For 1/23, 23 doesn't go into 1, or 10, but it goes into 100 four times, which is 92, leaving a remainder of 8. We then carry that 8 down.

Corey
So now we have 80. 23 goes into 80 three times, which is 69, leaving 11. Then 23 into 110 four times, 92, leaving 18. This process continues, producing a sequence of remainders.

Maria
Exactly. Each remainder will be less than 23. Since there are only 22 possible non-zero remainders, you are guaranteed to eventually repeat one of them. The worst-case scenario is that you use all n-1 possible remainders before repeating.

Corey
So that 60,017 that Shanks calculated, with 60,016 digits, basically used every single possible remainder before looping. That's a 'worst-case' prime in terms of period length.

Maria
It is! And the one before it, 60,013, only used 5,001 digits, which is less than 10% of the possible values. It's fascinating how different primes behave.

Corey
Surely Shanks wasn't doing this entire process, all 60,016 digits, with long division on paper, right? That would be an unfathomable amount of work.

Maria
I don't think he was. The amount of paper and time needed for a small number like 23, let alone 60,017, is immense. Plus, the types of errors he made are a clue.

Corey
What kind of errors did he make? Did he miscalculate a digit, or was it something more systematic?

Maria
He often corrected his results by doubling or halving the period length. For example, he thought one repeated every 30,525 digits, then corrected it to 61,050, exactly double. This suggests a different technique, perhaps involving powers of two or some halving steps, leading to systematic errors.

Corey
That's a great insight. It's like he had an algorithm, but sometimes made an error in applying a step, which then propagated. So he wasn't doing endless long division like we just did.

Maria
Exactly. He died in 1882, but he was still submitting results for primes up to 110,000 just a few years before his death. He also noted that his tables could be used to find reciprocals of composite numbers, not just primes.

Corey
So he saw practical applications for his work, even if it was just to calculate other related numbers. He sounds like a true enthusiast.

Maria
He definitely was. Imagine his YouTube channel if he were alive today! He'd be a sensation. I wonder what he would have thought of my ShanksBot, solving in seconds what took him years.

Corey
He might have been conflicted. On one hand, the goal achieved effortlessly. On the other, maybe it was the 'doing' that he loved. The struggle, the pursuit.

Maria
I agree, I think he enjoyed the process. You know, I've been doing a lot of research on him. Was he married?

Corey
Yes, he was. His wife actually outlived him by nearly two decades. I can just picture him, 'Morning, honey, off to work!' And his 'work' was walking upstairs to crunch numbers all day.

Maria
It truly puts his dedication into perspective. Now, there are some follow-up questions we could explore based on Shanks's work, like how to use prime reciprocals for composite numbers, as he mentioned.

Corey
That's interesting, linking primes to composites. And what about those primes, like 60,017 or 7, that use every single possible remainder before repeating? Is there a special name for them?

Maria
There is! It relates to something called a 'primitive root.' Primes that have 10 as a primitive root will exhibit this maximal period length, using every possible remainder. These are sometimes called 'Reptend primes'.

Corey
So, 60,017 is a Reptend prime because its reciprocal's period length is 60,016, which is n-1. That's a great definition!

Maria
Exactly. It's a prime that goes to the maximum length. There's so much more to delve into, but for me, the long division itself and Shanks's incredible perseverance are the most captivating parts.

Ask anything
We've read this whole study set, so questions about it get the best answers.