This may not be everyone’s (anyone’s?) cup of tea, but recently Derpetologist mentioned in the comments that he had noticed a certain property of prime numbers. I looked at it for a while and came up with a proof. R.J. suggested that I write an article on it, and Tonio was agreeable, so here we go for those who might find it interesting. If not, feel free to skip to the comments.

Derpetologist’s conjecture: The difference of the squares of any two prime numbers 5 or above is divisible by 6. (Whiz’s corollary: said difference is also divisible by 24.)

I worked out a detailed proof of the conjecture (and my corollary) using the fact that they are divisible only by 1 and themselves. But then I wondered if there is any profound significance to this property of primes. Is it in some way more general than just for primes? It turns out the answer is yes and it relies on the fact that in order to be divisible by 24, a number must be divisible by both 8 and 3. This led to two, more general, theorems, which when combined indicated there was a larger class of numbers that guarantees divisibility by 24. Note that all variables used below are integers.

Theorem 1: The differences of the squares of any two odd numbers is divisible by 8.

Proof: Any odd number can be written as 2n + 1. Therefore the difference of squares of any two odd numbers (not necessarily prime) is (2m + 1)^2 – (2n + 1)^2 = 4 (m n)(m + n + 1), which is clearly divisible by 4. Furthermore, if m and n are either both even or both odd, then mn is even and the difference is divisible by at least one more factor of 2, or, in total, by 8. If one of m and n is even and the other odd, then m + n + 1 is even and again the difference is divisible by at least one more factor of 2, and the difference is divisible by 8.  Q.E.D.

What about divisibility by 3? Is there any significance to the fact that the prime number 3 is excluded from the set of primes included in Derpetologist’s conjecture? It turns out that the answer to that is yes.

Theorem 2: The difference of squares of any two numbers that are not divisible by 3 is divisible by 3.

Proof: Any number not divisible by 3 (not necessarily prime or odd) can be written as 3n + 1 or 3n +2. Then for two different numbers of the first form, the difference of their squares is (3n + 1)^2 – (3m + 1)^2 = 3(nm)(3n + 3m +2), which is clearly divisible by 3. Similar computations can be made for any other combination of two numbers not divisible by 3, either one of the form 3n +1 and one 3n + 2, or both of the form 3n + 2; fleshing out those cases will be left as an exercise for the reader (!). Q.E.D.

Proof of the conjecture: Since all primes 5 or above are both odd and not divisible by 3, by Theorems 1 and 2 the difference of their squares is divisible by 8 and 3, respectively, and therefore also divisible by 24. Q.E.D.

Thus the original conjecture and corollary are true because all primes 5 or above are both odd and not divisible by 3, but other pairs of numbers that are not prime, but are odd and not a multiple of 3, also have the same property; for example, the difference of the squares of 35 and 25 is 600, which is 24 times 25. So primes 5 and above are just a subset of odd numbers whose difference of squares is divisible by 24.

It seemed to me that this property of primes was simple enough that it must have been known for a quite a while. After completing my proof, I looked for others, and found a different one that used Fermat’s little theorem (which I won’t describe here — you can look it up if interested). The other proof, however, was good only for primes 7 and above.