When I was a kid, I found an interesting property of the integers. I don’t claim it’s original to me, but people I’ve shown have gotten a kick out of it.
Well, okay. I showed it to my family when I was a kid, and bored at my grandparents’ house with a large supply of printer paper to do math on, and they were confused and perhaps annoyed.
Anyway, now I’ll show you. Very basic number theory makes it much easier to explain, but in this post I’ll only assume knowledge up to algebra one.
The Property
Take any two primes that are both greater than 3. Call them p and q. Square them both, take the difference, and the result will be divisible by 24. Or, in prettier form:
A few examples:
Check these if you like, or substitute your own numbers in; it’ll always work. If you’re into this sort of thing, now’s a good time to figure out why! Then you can read the rest of this post, and check your answer.
A Prerequisite
Before we get into the proof, we need to remark on relatively prime numbers. These are numbers that have no factors in common (except 1). A prime number is relatively prime to every number except itself and 1. 4 isn’t prime, and neither is 9, but these numbers have no factors in common, so they are relatively prime to each other.
For reasons this blog post is too small to contain, if two numbers are relatively prime, and a third number is divisible by both of them, that third number is also divisible by their product.
This fact may sound exotic, but it’s not that crazy in action. If a number is divisible by 2 and 5, then because no other number goes into both 2 and 5, that number is also divisible by 10. Likewise, a number divisible by both 2 and 3 is necessarily divisible by 6. Both these facts are pretty intuitive; the rule I’m gesturing at is just the more general version.
Anyway, 8 and 3 are relatively prime, so if a number is divisible by both 8 and 3, it’s also divisible by their product, which is 24.
The Proof
First, an observation. If a prime number is greater than 3, it is neither divisible by 2 or 3. In fact, our proof will hold for any number neither divisible by 2 or 3; it isn’t specific to primes. (You could try 49 for p or q, for example, and it would work.)
We will now split the proof into cases. First we’ll show that p squared minus q squared is divisible by 3, and then that it’s divisible by 8.
Case One: Divisibility by Three
We know p and q are both indivisible by three. Thus, each can be expressed as either having a remainder of 2 when divided by three, or a remainder of 1 (if the remainder was 0, it’d just be divisible).
So, either p = 3n + 1, or p = 3n + 2, for some n. Likewise, either q = 3m + 1, or q = 3m + 2, for some m. Let’s square these and see what happens. (Since they’re functionally the same, we’ll do just p.)
There’s a little sneakiness going on here, but what we’ve established is that if we square any number that’s not divisible by 3, we’ll end up with a number that has a remainder of one when divided by 3.1
Anyway, what happens when we take two numbers with a remainder of 1 when divided by 3, and subtract one from the other? The remainders cancel out! Or, more formally:
In this equation, c can be any integer; it doesn’t matter. The point is that the difference will be 3 times something, and thus divisible by 3. So we’re done with the first case. Now we need to do the same thing for 8, and we’re done.
Case Two: Divisibility by Eight
Make sure you understand the first case, because this one going to work about the same, and I’ll move a little faster.
p and q must be even. Thus, they have an odd remainder when divided by 8. It could be 1, 3, 5, or 7. Let’s expand each case.
The astute reader may notice that the terms with n in them don’t matter. The important bit is that 1 squared, 3 squared, 5 squared, and 7 squared each just so happen to, when divided by 8, have remainders of 1.
As in the 3 case, these remainders of 1 cancel out on subtraction. Or, to recapitulate the 3 case:
And So
Since our difference is divisible by both 3 and 8, it’s divisible by 24. Our proof is complete! I hope you liked it, and thanks for reading.
If this part isn’t clicking for you and you’re familiar with modular arithmetic, that’s another way of thinking about the problem: both 1 squared and 2 squared are equal to 1 mod 3.


Nice!
Small typo:
"Square them both" -> "Square them both, take the difference"