Modular arithmetic: you may not know it but you use it every day
That’s Maths: Modular arithmetic is used to calculate checksums for ISBNs and Ibans
You may never have heard of modular arithmetic, but you use it every day without the slightest difficulty. In this system, numbers wrap around when they reach a certain size called the modulus; it is the arithmetic of remainders. When reckoning hours, we count up to 12 and start again from one. Thus, four hours after 9 o’clock it is 1 o’clock. Numbers that differ by a multiple of the modulus 12 are said to be congruent modulo 12.
A similar situation arises for the days of the week, which are computed modulo seven. Suppose today is Thursday. What weekday will it be 1,000 days from today? We don’t have to count through the thousand days, just calculate the remainder when 1,000 is divided by seven, which is six. Then the weekday 1,000 days from today will be the same as in six days, a Wednesday.
It is much the same for other time measurements. With 52 weeks in a year, the week number is reset to 1 at the beginning of each year, so it is confined to the range 1 to 52. Likewise, for the months, we use modulo 12 arithmetic.
Modular arithmetic was introduced by Carl Friedrich Gauss on the very first page of his magnum opus Arithmetical Investigations, or Disquisitiones Arithmeticae. Gauss was one of the most brilliant mathematicians of all time. His genius became evident at an early age. His primary school teacher set a task for the class: hoping for some peace, he asked his pupils to add up the first 100 numbers. While his classmates attacked the problem head on, Gauss, who was just eight, spotted a pattern that led directly to the answer. He paired 1 with 100, 2 with 99 and so on to 50 with 51. Since each of the 50 pairs added to 101, the grand total must be 5,050. Gauss gave this correct answer within a minute or so, thwarting the teacher’s plan.
Historians have not recorded the reaction of the teacher, but he might have gained some respite by asking Gauss for the product that results when the first hundred numbers are multiplied, a number called factorial 100, having 158 digits.
Disquisitiones Arithmeticae was completed when Gauss was only 21, and published three years later in 1801. This work revolutionised number theory, bringing together many previous results and containing much that was original. It was one of the last mathematical texts to be written in Latin. The logical structure of this book set a standard that was followed in many later texts. Gauss’s work extended the theory of numbers in several directions, and its influence continued into the 20th century.
Ibans and ISBNs
Modular arithmetic is used extensively in pure mathematics, where it is a cornerstone of number theory. But it also has many practical applications. It is used to calculate checksums for international standard book numbers (ISBNs) and bank identifiers (Iban numbers) and to spot errors in them.
Modular arithmetic also underlies public key cryptography systems, which are vital for modern commerce. It is also widely used in computer science. Finally, in music theory, modulo 12 arithmetic is used to analyse the 12-tone equal temperament system, when notes separated by an octave of 12 semi-tones are treated as equivalent.