The following riddle was posed on last week's Car Talk:
A student is asked if the following number is a perfect square: 334,912,740,121,562. Crusty knows the answer immediately. What does Crusty know?
When I heard it, I thought about
quadratic residue but that seemed rather technical for Car Talk. Maybe there is a trick that I was missing. Well, they didn't use the words "quadratic residue" but Ray gave the solution thusly: There are no perfect squares which have a units digit of 2 -- it's impossible! ... Why? Because the units digit of any perfect square is determined by the units digit of its square root.
Now, the statement is true but it doesn't fully explain why. Ray says "try it!" and lists some examples:
12 = 1, 22 = 4, 32 = 9, 42 = 16, etc.
Let's look at the units digit for the first several perfect squares:
1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256
So far, the only digits we have seen in the units place are 0, 1, 4, 5, 6, or 9. At this point we can CONJECTURE that these are the only possibilities. However, this should leave you feeling empty inside, as if you just drank a whole pot of coffee without eating any breakfast. The good news is that this conjecture is easy to verify! So I decided to write another journal entry in my series of "proofs for non-math people" which you can survey by clicking the "math" tag on this entry. The first thing we do when writing a proof is to carefully establish what it is we want to prove.
Want to show: For any whole number n, the square of that number has one of 0,1,4,5,6,9 in the ones place.
First of all, let's review place value. The three-digit number 256 means 200 + 50 + 6; the rightmost digit 6 refers to, well, 6. The rightmost position in the whole number is called the units (or ones) place. The position immediately to the left is the tens place, so the digit 5 refers to 5 tens. Likewise for the 2 in the hundreds place.
One more thing to review and then we can start the proof. Remember how to square a binomial using FOIL (first + outside + inside + last)? The key identity for our purposes is:
(a + b)2 = a2 + 2ab + b2
Now let's prove the conjecture. It begins "For any whole number n" so let n be any whole number. Ray indicated that the units digit determines the units digit in the square, so we want to separate out the units digit in n. The way we do this is to write n = 10a + b. For example, if n = 256 then we would write it as 25(10) + 6.
Okay, so n = 10a + b, then n2 = (10a)2 + 2(10a)(b) + b2.
Look at the first two terms there: (10a)2 + 2(10a)(b) Both of them have a factor of 10, so that part of the n2 is a whole number that ends with 0 in the units place. (Multiply a whole number by 10 and you get a number that ends in 0.) So it's that part plus b2, and remember b is the digit in the units place of n. So whatever the units place digit of b2 is, that's going to be the units place digit of n2.
Thus we have verified Ray's assertion that the units place digit of the number determines the units place digit of the square of that number. We only have 10 possible digits for that units place, so we can determine all of the possible outcomes and they are 0, 1, 4, 5, 6, and 9. Ta-dah!
The proof is complete. Notice that this proof can be applied to any base number system, for example hexadecimal is base-16. Despite having more possible digits, it has fewer possible units for a perfect square; they are 0, 1, 4, and 9.
PS. Just because a decimal whole number ends in 0, 1, 4, 5, 6, or 9, this DOES NOT imply that it is a perfect square. Obviously 15 is not a perfect square. Our conjecture is a one-way implication, in particular the implication is IF n is a whole number THEN n2 must end with 0, 1, 4, 5, 6, or 9. It does not generally work in reverse. The way Crusty used this in the Puzzler is by contrapositive, i.e. n2 does NOT end in 0, 1, 4, 5, 6, or 9 therefore n is NOT a whole number.