Wednesday, November 11, 2009

Wednesday Math, Vol. 96: repeating patterns in decimals


Nowadays, people tend to like decimals more than fractions, largely because calculators give answers in decimals. Each system has its advantages. If two numbers are in decimal form, it's very easy to tell which one is bigger. That isn't always the case for numbers in fractional form. The advantages of fractional form are precision and compactness.

The difference between rational numbers and irrational numbers in decimal form is that eventually, a rational number will repeat some finite pattern of digits over and over forever. In standard math notation, we put a line over the repeated part, but that's hard to do in the editor for Blogger, so instead, I'm going to write the repeated part in red. For the fraction 1/2, the repeated part is a zero, so usually, we just write .5, but it's also correct to write .50 or .500 or even .50, with an infinite number of zeros after the 5. The repeated pattern is one digit long.

If we have a fraction, can we know how long the repeated pattern will be? Let's look at the fractions 1/2 to 1/13.

1/2 = .50
1/3 = .3
1/4 = .250
1/5 = .20
1/6 = .16
1/7 = .142857
1/8 = .1250
1/9 = .1
1/10 = .10
1/11 = .09
1/12 = .083
1/13 = .076923

As we can see, the repeated decimal pattern is only one digit long for many of these fractions, except for 1/7, 1/11 and 1/13. As you might guess, the thing 7, 11 and 13 have in common is that they are prime.

This question delves into number theory, and it was Carl Friedrich Gauss, genius and jerk, who figured out the basics. If p is a prime number, then 1/p will have a repeating pattern of length at most p-1. If the pattern isn't as long as possible, the pattern length will have to divide p-1.

Let's report on the primes on the list.

2: 2-1 = 1. The length of the repeating pattern has to be 1.
3: 3-1 = 2. The length of the repeating pattern has to be 1 or 2. In base 10, the length is 1.
5: 5-1 = 4. The length of the repeating pattern has to be 1 or 2 or 4. In base 10, the length is 1.
7: 7-1 = 6. The length of the repeating pattern has to be 1 or 2 or 3 or 6. In base 10, the length is 6.
11: 11-1 = 10. The length of the repeating pattern has to be 1 or 2 or 5 or 10. In base 10, the length is 2.
13: 13-1 = 12. The length of the repeating pattern has to be of length 1, 2, 3, 4, 6 or 12. In base 10, the length is 6.

Some primes have the longest pattern possible. The pattern for 1/17 repeats every 16 digits.

1/17 = .0588235294117647

Some are remarkably tidy. 1/37, which could have a pattern 36 digits long, has a pattern that repeats in 3 digits.

1/37 = .027

On the other hand 1/1369, where 1369 = 37*37, has a pattern that is 3*37 = 111 digits long. I'm not printing that one out, if it's all the same to you.

If we dealt in bases other than base 10, the digit representations change and so do their lengths, but not the rules about primes and the length of the pattern for 1/p having a length that divides p-1.

Having called Gauss a jerk a few months back, I want to re-iterate that he is clearly a genius first and a jerk second.
~

1 comment:

Anonymous said...


I am searching for things to improve my website! I assume its ok to use some of the ideas!