Had you asked G H Hardy – the Cambridge scholar responsible for myriad seminal mathematical results and developments of the early 20th century – what his favorite area of math was, he’d answer without hesitation: number theory.
It is, he wrote in A Mathematician’s Apology, “one of the most obviously useless branches” of math, and so those who study it “may be justified in rejoicing that [its] very remoteness from ordinary human activities should keep it gentle and clean.”
Well, no disrespect to Hardy, but he couldn’t be more wrong about that. Since his death in 1947, the world has seen the rise of public-key encryption schemes such as RSA; computer systems to generate random (or at least, pseudorandom) numbers; countless computer algorithms for error correction and image generation and storage; cellular communication networks, optimized with techniques based on the theory of modular forms – the list goes on, and on, and on.
But there’s one much more humble application of number theory that you might not have heard of – though it’s arguably far more important than, say, your cell signal. And if you want to see it for yourself, you need only look as far as your local supermarket.
What are check digits?
Imagine you’re a bartender in Florida, and a kid who looks barely old enough to vote hands you his driver’s license and asks for an old fashioned. Suspicious, you check the details on the card: you see a birthday of January 24, and a license number ending 162.
You turn him down with a scoff. “Nice try, kid,” you say, “but this ID is fake. Try the bar down the road; their servers haven’t heard of check digits.”
How did you know the kid was lying? Well, according to the Cornell Math Explorers’ Club, states like Illinois and Florida have particular rules about how they create driver’s license numbers. They take into account your name, sex, and date of birth – and they add a check digit at the end.
But what does that mean? Well, a check digit is pretty much what it sounds like: it’s a digit (or digits) that provides a way to check the number before it. It’s kind of a security feature, but not one that’s of vital importance – rather than protecting against identity theft or something, it’s more there to make sure you don’t accidentally swap two numbers around, or misread a scuffed-down 8 as a 3, for example.
So, for your Floridian driver’s license, the issuers “use linear functions to encode the month and date of birth into a three-digit number that is made into the last three digits of the driver’s license number,” the Explorers’ Club explains. “For males in Florida the last three digits are given by 40(m – 1) + b, where m is the month and b is the date of birth […] For a female they then add 500 to this number.”
A young man born on January 24, therefore, would have a license ending in 024 – that’s 40 × (1 – 1) + 24. The license you were handed in our hypothetical, ending 162? That would belong to someone born on May 2. It’s a fake.
Where do we find check digits?
We live in an age ruled by numbers, and as such, check digits have (ironically) innumerable uses. Books, for example, are universally identified by unique International Standard Book Numbers (ISBNs). These can be 10 or 13 digits long, depending on the age of the book, and the very last one of those is a check digit.
Unfortunately, finding that digit is a lot more complicated than the Florida driver’s license example. “Each of the first 12 digits of the ISBN is alternately multiplied by 1 and 3,” explains the ISBN Users’ Manual; “The check digit is equal to 10 minus the remainder resulting from dividing the sum of the weighted products of the first 12 digits by 10 with one exception. If this calculation results in an apparent check digit of 10, the check digit is 0.”
Other products don’t have ISBNs, but they do have universal product codes (UPCs), or to put it another way: those long strings of numbers you’ve seen underneath barcodes. Contained within those seemingly random codes are – you guessed it – check digits: “find an object with a 13-digit barcode. (If you are in the US, a 12-digit barcode will also work, if you imagine an extra 0 on the front of it),” writes Katie Steckles in New Scientist this month; “Add together the first, third, and fifth digits and so on, to get the sum of the odd-numbered digits; then, add up the even digits. If you triple the even sum, and then add it to the original odd sum, the total should be a multiple of 10, ending in 0.”
Credit cards have check digits, “meaning a website can tell you have entered it incorrectly before even checking with your bank,” Steckles explains; if you’re in the UK, the last element in your 10-digit NHS number is a check digit – to find it, just take the first nine digits; multiply the first by 10, the second by 9, the third by 8, and so on, and then add the results together. Divide the total by 11, and the remainder is your check digit (so, for example, an NHS number starting 555555555 would have to end in a 6 – because 50 + 45 + 40 + 35 + 30 + 25 + 20 + 15 + 10 = 270 = 24 × 11 + 6.)
Not foolproof – but useful
Check digits aren’t infallible – some algorithms can’t tell the difference between sequences like 1 and 00001, for example; others will catch incorrect digits, but miss swapped pairs. Even if the algorithm works perfectly, it might still fluke out and get the answer wrong – consider, for example, the barcode check digit algorithm: you’re working modulo 10, so there’s a one-in-ten chance it just works anyway.
But overall, check digits are a small cheat with a big payoff. They can save you hours of frustration wondering why your credit card details aren’t accepted, or give a quick way to check whether your car is sporting stolen VINs; they can provide an extraordinarily nerdy party trick, or ruin a hypothetical Floridian teen’s night.
And, much to Hardy’s chagrin, it’s all thanks to number theory. Long live the queen of mathematics.