Professional Documents
Culture Documents
Chapter 5 Codes Mathematical Systems
Chapter 5 Codes Mathematical Systems
MODULAR
ARITHMETIC
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.
The first three digits of an ISBN are 978, the next digit indicates
the country in which the publisher is incorporated (0, and
sometimes 1, for books written in English), the next two to seven
digits indicate the publisher, the next group of digits indicates
the title of the book, and 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
chosen to satisfy the following congruence.
Formula for the ISBN Check Digit
= 10 - 124 mod 10
= 10 - 4
= 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.
Determine a Check Digit for an ISBN
1. Determine the ISBN check digit for the book The
Equation that Couldn’t Be Solved by Mario Livio. The
first 12 digits of the ISBN are 978-0-7432-5820-__.
2. A purchase order for the book The Mathematical Tourist
by Ivars Peterson includes the ISBN 978-0-76073261-
6.Determine whether this is a valid ISBN.
3. Determine whether the given number is a valid ISBN
a. 978 – 0 – 614 – 35945 – 2
b. 978 – 1 – 55690 – 182 – 9
UPC (Universal Product Code)
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. If
the price of an item changes for a promotional sale, the price is
updated in the computer, thereby relieving a clerk of having to
reprice each item. In addition to pricing items, the UPC gives
the store manager accurate information about inventory and
the buying habits of the store’s customers.
UPC (Universal Product Code)
The UPC is a 12-digit number that satisfies a
congruence 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.
UPC (Universal Product Code)
The formula for UPC Check digit
Solution:
d12 = 10 – [3(7) + 8 + 3(6) + 9 + 3(3) + 6 + 3(7) + 9 + 3(7) + 9 + 3(8)] mod 10
= 10 – 155 mod 10
= 10 – 5
=5
The check digit is 5.
UPC: 7-86936-79798-5
UPC Example
The following are UPCs of Philippine
products. Identify the missing check digits.
a. Argentina beef loaf 170g: 7 – 48485 – 80009 -
𝒙𝟏𝟐
b. Nissin bowl Noodles Hot and Spicy Chicken
Flavor 3.32oz: 0 – 70662 – 09631 - 𝒙𝟏𝟐
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 four digits are used to identify the card issuer.
Credit Card Numbers
The table below shows the identification
prefixes used by four popular card issuers.
Card Issuer Master Prefix Number of
digits
Card 51 to 55 16
Visa 4 13 or 16
American Express 34 or 37 15
Discover 6011 16
Credit Card Numbers
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 equal 0 mod 10.
Determine a Valid Credit Card Number
Determine whether 5234 8213 3410 1298 is a valid credit card number.
Solution Highlight every other digit, beginning with the next-to-last digit
and reading from right to left.
5234821334101298
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, this is a valid credit card number.
USPS
Modular arithmetic is often used in coding
information. The United States Postal Service (USPS)
uses modular arithmetic to detect errors or forgeries
of money orders.
The serial number of a USPS money order is 11 digits
long. The first 10 digits of the serial number
(8810024532) are followed by a security check digit
(7). If the money order is genuine, then the 10-digit
number modulo 9 will be equal to the check digit.
USPS Problem
Money order A has a serial number of 51177875501. Money order
B has a serial number of 88100245327. Using modular arithmetic,
determine if the money orders are genuine.
Solution: For Money order A, the serial number is genuine if the
first 10 digits of the number is 10-digit code(mod 9) = 1. Notice
that 5117787550 = 568643061(9) + 1. Therefore, 5117787550(mod
9) = 1. Thus, the serial number corresponds with a genuine money
order. For Money order B, notice that 8810024532 =
978891614(9) + 6. Therefore, 8810024532(mod 9) ≠ 7. Thus, the
serial number does not correspond with a genuine money order.
Cryptology
Cryptology is the discipline devoted to secrecy
systems.
Cryptography is a branch of cryptology that deals with
the design and implementation of secrecy systems
Cryptanalysis involves breaking these secrecy systems.
Plaintext is a message that is to be altered into a
secret form.
CRYPTOGRAPHY
Cipher refers to the method for altering a
plaintext message into a cipher text. Changing
the letter of the plaintext uses a transformation.
Key determines a particular transformation from
a set of possible transformations.
Encryption or enciphering is the process of
changing plaintext into cipher text.
Decryption or deciphering is the reverse process
of changing the cipher text back to the plaintext.
SECRECY SYSTEMS encryption
A. SHIFT TRANSFORMATIONS
Form: C ≅ P + k (mod 26), 0 ≤ C ≤ 25,
where:
Form: C ≅ P + 3(mod26), 0 ≤ C ≤ 25
CORRESPONDENCE BETWEEN PLAINTEXT
AND CIPHERTEXT(CAESAR’S CIPHER)
Plainte
xt A B C D E F G H I J K L M
Ciphert
ext D E F G H I J K L M N O P
Plainte
xt N O P Q R S T U V W X Y Z
Ciphert
ext Q R S T U V W X Y Z A B C
Example: Encipher the message using
Caesar’s:
Answer:
EHZDUH WKH LGHV RI PDUFK
B. AFFINE TRANSFORMATIONS
Form: C ≅ aP + b (mod 26), 0 ≤ C ≤ 25
Where:
Key K = (a, b), a and b are integers,
P is the numerical equivalent of a letter in the
plaintext, and
C is the numerical equivalent of the corresponding
cipher text letter.
Encipher the message using affine
transformations C = 3P + 1 (mod 26)
Example:
LASER PRINTER
Decode the message IGHT OHGG,
which was encrypted using the
congruence
c ≡ (7p+1) mod 26 to encode the
message: