Professional Documents
Culture Documents
A. Modular Arithmetic
-is a special type of arithmetic that involves only integers. Where numbers wrap around upon reaching a
certain value, which is the modulus.
I. Introduction
a ≡ b (mod n)
1. a and b have the same "remainder" when they are divided by n.
2. a ≡ k • n + b
3. n | (a - b)
EX1:
10 ≡ 14 (mod 4)
1. a ≡ b (mod n)
10 ÷ 4 ≡ 2 R2
14 ÷ 4 ≡ 3 R2
2. a ≡ k • n + b
10 ≡ -1 • 4 + 14
3. n | (a - b)
4 | (10 - 14)
4 | (-4)
-4 ≡4 (-1)
EX2:
7 + 8 ≡ 3 (mod 12)
1. a ≡ b (mod n)
7 + 8 ≡ 3 (mod 12)
15 ≡ 3 (mod 12)
15 ÷ 12 ≡ 1 R3
3 ÷ 12 ≡ 0 R.25/ R3
2. a ≡ k • n + b
15 ≡ 1 • 12 + 3
3. n | (a - b)
12 | (15 - 3)
12 | (12)
12 ≡ 12 (1)
B. Applications of Modular Arithmetic
I. ISBN numbers for published books.
The ISBN number for our textbook is 0-13-184-868-2.
The information is decoded in the first 9 digits. The last digit is for parity
check
(1 x a1) + (2 x a2) ... + (9 x a9) = a10 (mod 11)
Applying this to our textbook
(1 x 0) + (2 x 1) + (3 x 3) + (4 x 1) + (5 x 8) + (6 x 4) + (7 x 8) + (8 x 6) + (9 x
8) = 255 = 2 mod 11
The sum of 9 digits is 255 and it equals to the last digit mod 11.
Example
In this example, the above algorithm for D mod 97 will be applied
to D = 3214282912345698765432161182. (The digits are colour-coded to aid the description below.)
If the result is one, the IBAN corresponding to D passes the check digit test.
1. Construct N from the first 9 digits of D
N = 321428291
2. Calculate N mod 97 = 70
3. Construct a new 9-digit N from the above result (step 2) followed by the next 7 digits
of D.
N = 702345698
4. Calculate N mod 97 = 29
5. Construct a new 9-digit N from the above result (step 4) followed by the next 7 digits
of D.
N = 297654321
6. Calculate N mod 97 = 24
7. Construct a new N from the above result (step 6) followed by the remaining 5 digits of D.
N = 2461182
8. Calculate N mod 97 = 1
From step 8, the final result is D mod 97 = 1 and the IBAN has passed this check digit test.
III. Cryptography
In cryptography, modular arithmetic directly underpins public key systems such
as RSA and Diffie–Hellman, and provides finite fields which underlie elliptic curves, and is used in a
variety of symmetric key algorithms including Advanced Encryption Standard (AES), International
Data Encryption Algorithm (IDEA), and RC4. RSA and Diffie–Hellman use modular exponentiation.
RSA
V. In computer science, modular arithmetic is often applied in bitwise operations and other
operations involving fixed-width, cyclic data structures. The modulo operation, as implemented in
many programming languages and calculators, is an application of modular arithmetic that is often
used in this context. The logical operator XOR sums 2 bits, modulo 2.
VI. In music, arithmetic modulo 12 is used in the consideration of the system of twelve-tone equal
temperament, where octave and enharmonic equivalency occurs (that is, pitches in a 1∶2 or 2∶1 ratio
are equivalent, and C-sharp is considered the same as D-flat).
VII. The method of casting out nines offers a quick check of decimal arithmetic computations
performed by hand. It is based on modular arithmetic modulo 9, and specifically on the crucial
property that 10 ≡ 1 (mod 9).
Examples:
-one way to determine the day of the week of a given date is to assign codes to the years, months and
dates such that:
Day of the week ≡ year code
+ month code
+ date (mod 7)