Monday, 11 August 2008

Things I learned Late in Life about Repeating Decimals and Prime Divisors

In my last blog I mentioned that if you write out any three digit number and repeat it two times it will be divisible by 7, and 13. I didn't mention it, but it will also be divisible by 11. The question of course is a) why, and b) how does that help us understand divisibility and primes. The easy reason is that any such number, xyzxyz, is going to have a factor of 1001 (xyz) and since 7, 11, and 13 all are factors of 1001, they will divide into it evently. Now if you repeat a two digit number 3 times (xyxyxy) then you get a number that is divisible by 7 and 13, and 37, but not 11. I'm not sure it works for all numbers, but I have noticed some patterns in what I am going to call the "modular sequence" of prime numbers. Becuase it is short and easy to check on your calculator, I will use 7 and 13 for examples, and then show some extensions for others.... so here goes.

The modular sequence of 7 is 5,4,6,2,3,1... Ok.. what does that mean... look at the 2, it is in the hundreds place... Suppose I take a number, 243 and find the remainder on division by 7. (in this case 243 mod 7 == 5). If you increase the number by 100, the remainder will increase by 2.. (343 mod 7 == 5+2 == 0; and 443 mod 7 == 0+2==2); and similarly an increase in the value of the number by 1000 would increase the remainder by 6 (or reduce it by 1, which is the same thing.... imagine that 13 divided by 7 is one with a remainder of six, but you could think of it as two with a remainder of negative one).

Now how does that help us explain the fact that 7 divides xyxyxy and xyzxyz. One way to find the remainder that I mentioned earlier is to use the dot product of the vector x,y,x,y,x,y times the modular sequence, 5,4,6,2,3,1. You end up with 14x + 7y which is of course divisible by 7 because both the 14 in the first term and the 7 in the second are divisible by 7. In the same way, the dot product of xyzxyz and 546231 will give us 7x+7y+7z, which is also divisible by 7. And just as an added treat, xxxxxx will also be divisible by 7 because the totatl of all the numbers in the modular sequence is 21, so the dot product would be 21 x.

Ok, a little more about the modular sequence to help you see the patterns that I think are true. THe modular sequence is the same length as the repeat cycle of the unit fraction 1/p. For example, 1/7 and 1/13 both are repeating decimals of length 6. 1/7 = .142857.... and 1/13 = .076923...The modular sequence for 13 is 4, 3, 12, 9, 10, 1. If we add up all the numbers we see that the sum is 3 (13) = 39 [remember that the sequnce for 7 summed to 3(7)] So let's form a rule.. it works, you can check it later. THe sum of the terms in the modular sequence will be p(n)/2 where p is the prime number in question, and n is the length of the sequence. [A similar formula holds for the sum of the digits in the repeating cycle of 1/p, the sum of the digits will be 9d/2... every repeating cycle has a digit sum which is a multiple of nine].

If the length n is divisible by some number x, then the sum of every xth digit in the modular sequence will add to a multiple of p. This is what we saw with every second digit of the sequence for seven (5+6+3=14 and 4+2+1=7) . Since the length of 1/13 is also six digits, we can do the same with the alternate digits of the modular sequence for 13 ( 4, 3, 12, 9, 10, 1) 4+12+10 = 26 and 3+9+1=13... (not able yet to explain the 2:1 ratio, or if it persists in all even length sequences). If we add every third digit for seven we get 5+2=4+3=6+1. For 13 we get 4+9=3+10=12+1. A similar idea works in the repeat cycle of any prime for which the length of the cycle is divisible by two; all the numbers in the last half are the nines complement of the numbers in the first half... 1/7 = 142857... look at 142 and then 857; 1+8=9 and the same for each digit. That was a trick I showed earlier to complete long strings on your calculator.

Ok, how about a harder one.. 1/17 has a repeating decimal 16 digits long, .0588235294117647 (for decimals 1/p if you want to see the back half of the sequence, do (p-1)/p on your calculator... look at 16/17 on your calculatror for instance) First, confirm that the corresponding numbers in each half add up to nine. 0+9, 5+4, etc.. Now in the modular sequence for 17, they will add up to 17, so when we have the first half, we can just use compliments to get the second half. FOr 17 the sequence is 12, 8, 11, 13, 3, 2, 7, 16, 5, 9, 6, 4, 14, 15, 10, 1. Take a moment to see that the corresponding parts in each half add up to 17....

Now my conjecture is that if the length n is divisible by d, then any number of d digits repeated enough times to make d digits will be divisible by p, in this case, 17. If this is true then in the modulus the numbers located d units apart must add up to a multiple of p. OK, so 2 divides 16, so every other number should add up to a multple of 17; 12+ 11+3+7+5+6+14+10=68 which is 4x17, and 8+13+2+16+9+4+15+1=68 also. Ok, it works for two, but four also divides 16, so every fourth number should add up to a multple of 17 as well. The first set would be 12+ 3+ 5+14=34 which is 2x17 (are YOU seeing a pattern?)... the second is 8+2+ 9+ 15= 34.. you try the other two.

If you want to play around with this some more, as I do, Here is some information of interest:

The length of the divisors, and some of the repeating digits and modular sequences that I have done so far out of the first few primes

n a(n) repeat seq mod seq

2 0

3 1 .3 1

5 0

6 1 6 4

7 6 142857 5,4,6,2,3,1

11 2 09 10,1

13 6 076923 4, 3,12,9,10,1

17 16 0588235294117647 2, 8, 11, 13, 3, 2, 7, 16, 5, 9, 6, 4, 14, 15, 10, 1

19 18 052631578947368421 2, 4, 8, 16, 13, 7, 14, 9, 18, 17, 15, 11, 3, 6, 12, 5,10,1

23 22 0434782608695652173913

29 28 0344827586206896551724137931

31 15 032258064516129

37 3 027 26,10,1

41 5 02439 37,16,18,10,1

43 21

47 46 0212765957446808510638297872340425531914893617

53 13

NOtice that the numbers whose sequence lengths are not divisible by two (such as 31 or 41) do not yield complimentary halfs, but they should still obey the division rules. (I hope that pqrstpqrstpqrst will be divisible by 31 since it repeats a sequence of five digits three times,) Have fun...

No comments: