0% found this document useful (0 votes)
11 views

5.2 Applications of Modular Arithmetic

Uploaded by

Lara Balangiao
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

5.2 Applications of Modular Arithmetic

Uploaded by

Lara Balangiao
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 53

Objectives

At the end of this section, the students are


expected to:
1. determine a check digit of ISBN or UPC using
modular arithmetic;
2. identify the validity of a credit card number,
ISBN, and UPC using modular arithmetic; and
3. apply modular arithmetic in encoding or
decoding a message.
ISBN and UPC
ISBN
Every book that is cataloged in the Library of
Congress must have an ISBN (International
Standard Book Number). This 13-digit
number was created to help ensure that
orders for books are filled accurately and
that books are catalogued correctly.
ISBN
The first three digits of an ISBN are 978 (or
979), followed by 9 digits that are divided
into three groups of various lengths. These
indicate the country or region, the publisher,
and the title of the book. The last digit (the
13th one) is called a check digit.
If we label the first digit of an ISBN d1, the second
digit d2, and so on to the 13th digit d13, then the
check digit is given by the following modular formula.

Formula for the ISBN Check Digit


d13 = 10 – (d1 + 3d2 + d3 + 3d4 + d5 + 3d6 + d7 + 3d8 +
d9 + 3d10 + d11 +3d12) mod 10.
If d13 = 10 then the check digit is 0.
It is this check digit that is used to ensure accuracy.
Suppose, however, that a bookstore clerk sends an
order for the American Heritage Dictionary and
inadvertently enters the number 978-0-395-28517-4,
where the clerk transposed the 8 and 2 in the five
numbers that identify the book.
Correct ISBN: 978-0-395-82517-4
Incorrect ISBN: 978-0-395-28517-4.
d13 = 10 – [ 9 + 3(7) + 8 + 3(0) + 3 + 3(9) + 5 + 3(2) + 8
+ 3(5) + 1 + 3(7) ] mod 10
= 10 – 124 mod 10
= 10 – 4 = 6

The receiving clerk calculates the check digit as 6.


Because the check digit is 6 and not 4 as it should be,
the receiving clerk knows that an incorrect ISBN has
been sent.
Transposition errors are among the most frequent
errors that occur.
The ISBN coding system will catch most of them.
Example 5.2.1 Determine the ISBN check digit for the
book Elementary Number Theory and Its Application by
Kenneth Rosen. The first 12 digits of the ISBN are 978-0-
321-50031-?
Solution.
d13 = 10 – [ 9 + 3(7) + 8 + 3(0) + 3 + 3(2) + 1 + 3(5) + 0 +
3(0) + 3 + 3(1) ] mod 10
= 10 – 69 mod 10
= 10 – 9 = 1
The check digit is 1.
Example 5.2.2 A purchase order of the
book Explorations in General Biology by
Joseph A. Marshall includes the ISBN 978 -
0 – 072 - 30129 - 8. Determine whether
this is a valid ISBN.
Solution.
Solving for the check digit, we get
d13 = 10 – [ 9 + 3(7) + 8 + 3(0) + 0 + 3(7) + 2 + 3(3)
+ 0 + 3(1) + 2 + 3(9) + 8 ] mod 10
= 10 – 102 mod 10
= 10 – 2 = 8.

Therefore, the ISBN 978 - 0 – 072 - 30129 - 8 is


valid.
UPC
Another coding scheme that is closely related to the ISBN is
the UPC (Universal Product Code). This number is placed on
many items and is particularly useful in grocery stores.

A check-out clerk passes the product by a scanner, which


reads the number from a bar code and records the price on
the cash register.
The UPC is a 12-digit number that satisfies a
modular equation that is similar to the one for
ISBNs. The last digit is the check digit. If we
label the 12 digits of the UPC as
d1, d2, ... , d12, we can write a formula for the
UPC check digit d12.
Formula for the UPC Check Digit

d12 = 10 – (3d1 + d2 + 3d3 + d4 + 3d5 + d6 + 3d7 +


d8 + 3d9 + d10 + 3d11 ) mod 10.

If d12 = 10, then the check digit is 0.


Example 5.2.3 Find the check digit for the UPC
of the SPAM(Hormel Foods). The first 11 digits
are 0-37600-70516-?
Solution.
d12 = 10 – [ 3(0) + 3 + 3(7) + 6 + 3(0) + 0 +
3(7) + 0 + 3(5) + 1 + 3(6) ] mod 10
= 10 – 85 mod 10 = 10 – 5 = 5
The check digit is 5.
Example 5.2.4 Is 1 – 32342 – 65933 – 7 a valid UPC?
Solution.
d12 = 10 – [ 3(1) + 3 + 3(2) + 3 + 3(4) + 2 + 3(6) + 5 +
3(9) + 3 + 3(3) ] mod 10
= 10 – 91 mod 10 = 10 – 1 = 9

Therefore, 1 – 32342 – 65933 – 7 is an invalid UPC.


TRY THIS!
Find the correct check digit for the UPC.
1. 0-79893-46500
2. 7-14043-01126
Credit Card Numbers
Companies that issue credit cards also use modular
arithmetic to determine whether a credit card
number is valid.

This is especially important in e-commerce, where


credit card information is frequently sent over the
Internet. The primary coding method is based on the
Luhn algorithm, which uses mod 10 arithmetic.
Credit card numbers are normally 13 to 16
digits long. The first one to six digits are
used to identify the card issuer.
The table below shows some of the
identification prefixes used by four popular
card issuers.
The Luhn algorithm, used to determine whether a
credit card number is valid, is calculated as follows:
Beginning with the next-to-last digit (the last digit is
the check digit) and reading from right to left,
double every other digit.
If a digit becomes a two-digit number after being
doubled, treat the number as two individual digits.
Now find the sum of the new list of digits;
the final sum must be congruent to 0 mod
10. The Luhn algorithm is demonstrated in
the next example.
Example 5.2.5 Determine whether 5143
6332 4510 1589 is a valid credit card
number.
Solution.
Highlight every other digit, beginning with
the next-to-last digit and reading from
right to left.

Next double each of the highlighted digits.


10 2 6 4 16 2 2 3 6 4 2 0 2 2 18 8
Finally, add all digits, treating two-digit
numbers as two single digits.

1+0+2+6+4+1+6+2+2+3+6+4
+ 2 + 0 + 2 + 2 + 1 + 8 + 8 = 60
Because 60 ≡ 0 mod 10, 5143 6332 4510
1589 is a valid credit card number.
Cryptology
Now find the sum of the new list of digits;
the final sum must be congruent to 0 mod
10. The Luhn algorithm is demonstrated in
the next example.
Related to codes on books and grocery items are
secret codes. These codes are used to send
messages between people, companies, or nations.
It is hoped that by devising a code that is difficult to
break, the sender can prevent the communication
from being read if it is intercepted by an
unauthorized person.
Cryptology is the study of making and breaking
secret codes.
Before we discuss how messages are coded, we need
to define a few terms. Plaintext is a message before it
is coded.
The line
SHE WALKS IN BEAUTY LIKE THE NIGHT
from Lord Byron’s poem “She Walks in Beauty Like
The Night” is in plaintext.
Ciphertext is the message after it has been
written in code. The line

ODA SWHGO EJ XAWQPU HEGA PDA JECDP

is the same line of the poem in ciphertext.


The method of changing from plaintext to
ciphertext is called encryption.
The line from the poem was encrypted by
substituting each letter in plaintext with the letter
that is 22 letters after that letter in the alphabet.
(Continue from the beginning when the end of the
alphabet is reached.) This is called a cyclical coding
scheme because each letter of the alphabet is
shifted the same number of positions.
The original alphabet and the substitute
alphabet are shown below.

To decrypt a message means to take the


ciphertext message and write it in plaintext.
If a cryptologist thinks a message has been
encrypted using a cyclical substitution code like
the one shown previously, the key to the code can
be found by taking a word from the message
(usually one of the longer words) and continuing
the alphabet for each letter of the word.
When a recognizable word appears, the key can
be determined.
Example 5.2.6 Use the cyclical alphabetic
encrypting code that shifts each letter 11 positions
to

a. code CATHERINE.
b. decode TGLY ESP EPCCTMWP.

=
If the encrypting code is to shift each letter of the plaintext
message m positions, then the corresponding letter in the
ciphertext message is given by
c  (p + m) mod 26 where
m is the number of positions the letter is shifted
p is the numerical equivalent of the plaintext letter
c is the numerical equivalent of the ciphertext letter.
Solution:
a. The encrypting congruence is
c  (p + 11) mod 26. Replace p by the
numerical equivalent of each letter of
plaintext and determine c.
m = 11, the number of positions the letter is
shifted
The results for CATHERINE are shown below.

Continuing, the plaintext would be coded as


NLESPCTYP ESP RCPLE.
Once plaintext has been converted to ciphertext,
there must be a method by which the person
receiving the message can return the message to
plaintext. For the cyclical code, the congruence is
p  (c + n) mod 26 where
p and c are defined as before and n = 26 – m.
b. Because m = 11, n = 26 – 11 = 15. The ciphertext is
decoded by using the congruence
p  (c + 15) mod 26. The results for TGLY are shown
below.

Continuing, the ciphertext would be decoded as


IVAN THE TERRIBLE.
The practicality of a cyclical alphabetic coding
scheme is limited because it is relatively easy for a
cryptologist to determine the coding scheme.

A coding scheme that is a little more difficult to break


is based on the congruence c  (ap + m) mod 26,
where a and 26 do not have a common factor.
Example 5.2.7 Use the congruence
c  (5p + 2) mod 26 to encode the message
LASER PRINTER.
Solution:
The encrypting congruence is c  (5p + 2) mod 26 .
Replace p by the numerical equivalent of each letter
from Table 8.1 and determine c.

Numerical Equivalents for the Letters of the Alphabet


The results for LASER are shown below.

Continuing, the plaintext is coded in ciphertext as


JGSAN DNUTXAN.
Decoding a message that was encrypted using
the congruence c  (ap + m) mod n requires
solving the congruence for p. The method
relies on multiplicative inverses which were
discussed previously. For example, decode the
message JGSAN DNUTXAN which was
encrypted using the congruence c  (5p + 2)
mod 26.
Solution:
Here, we solve the congruence equation
for p. c = 5p + 2
c – 2 = 5p
21 (c – 2) = 21 (5p) Multiply both sides of the
equation by the multiplicative inverse of
5 with respect to mod 26. Note 21. 5 ≡ 1 mod 26
Therefore, [ 21 (c – 2) ] mod 26 ≡ p.
Using this congruence equation, we can decode the ciphertext
message JGSAN DNUTXAN.
J [ 21(10 – 2)] mod 26 168 mod 26 = 12 Decode J as L.
G [ 21(7 – 2)] mod 26 105 mod 26 = 1 Decode G as A.
S [ 21(19 – 2)] mod 26 357 mod 26 = 19 Decode S as S.
A [ 21(1 – 2)] mod 26 (-21) mod 26 = 5 Decode A as E.
N [ 21(14 – 2)] mod 26 252 mod 26 = 18 Decode N as R.
Continuing, we would decode the message as
LASER PRINTER.
Example 5.2.8 Decode the message
ACXUT CXRT, which was encrypted using
the congruence c  (3p + 5) mod 26.
Solution.
Solve the congruence equation for p.

The decoding congruence is .


Using this congruence, we will show the details
for decoding ACXUT.

Continuing, we would decode the message as


PHONE HOME.
1. Find all whole number solutions to each of the following congruence equations:
a. 4x + 1 ≡ 9 𝑚𝑜𝑑 5
b. 6x −2 ≡ 4 𝑚𝑜𝑑 15
2. What is the check digit for the UPC 7-14043-01126-?
3. Which of the following is a valid ISBN?
a. 978-0-7334-2609-6
b. 978-3-16-148410-0
4. Is 5167 4871 8954 1711 a valid credit card number?
5. Using the congruence 𝑐 ≡ 5𝑝 + 6 mod 26, what is the exact plaintext behind BTYW
SCRBKN?
1) Augustine, K. (2018). Algebra, Arithmetic, Statistics, and Probability. A Mathematical Book
for High Schools and Colleges.
2) Burton, D. (2011). Elementary Number Theory, Seventh Edition. The McGraw Hill Companies.
3) Daligdig, R.M. (2019). Mathematics in the Modern World. Lorimar Publishing, Inc.
4) Carpio, J.N. and Peralta, B.D. (2018). Mathematics in the Modern World. Books Atbp.
Publishing Corp.
5) Finston, D. (et al) (2014). Abstract Algebra Structure and Application. Springer International
Publishing Switzerland.
6) Olejan, R.O., Veloria, E.V., Bonghanoy, G.B., Ondaro, J.E.,and Sumalinog, J.D. (2018).
Mathematics in the Modern World. MUTYA Publishing House, Inc.
7) Manlulu, E.A. and Hipolito, L.M. (2019). A Course Module for Mathematics in the Modern
World. Rex Book Store, Inc.
8) Zhou, X. (2015). Number Theory Modular Arithmetic. Math for Gifted Students.
http://www.mathallstar.org.

You might also like