0% found this document useful (0 votes)
19 views62 pages

Logic and Set Theory

About Modular arithmetic

Uploaded by

Isabelle Pascual
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views62 pages

Logic and Set Theory

About Modular arithmetic

Uploaded by

Isabelle Pascual
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 62

MODULAR

ARITHMETIC
by: Justine Blu Delfin

INSPIRED BY
MODULAR
ARITHMETIC
- In mathematies, modular
mathematics (sometimes known as
clock arithmetic) is a special type of
arithmetic that makes use of only
integers, where numbers "wrap
around" upon reaching a given fixed
quantity.
- Modular arithmetic was developed
by German mathematician and
physicist Carl Friedrich Gauss (1777-
1855) in his book Disquisitiones
Arithmeticae, published in 1801
Carl Friedrich Gauss (1777- 1855)
12-HOUR
CLOCK
- A familiar use of modular arithmetic
is in the 12-hour clock
- which has the time period divided
into two equal halves: a.m. (from
Latin ante meridiem, translates to,
before midday) and p.m. (from Latin
post meridiem translates to, past
midday).
12-HOUR
- To denote addition on a 12-hour
clock, we will use the symbol ⊕.
- To denote subtraction on a 12-hour
CLOCK
clock, we will use the symbol ⊖.

Examples:
Calculate using a 12-hour clock

8 ⊕ 10
6⊕7
10 ⊕ 6
5⊖8
3 ⊖ 11
12-HOUR
- To denote addition on a 12-hour
clock, we will use the symbol ⊕.
- To denote subtraction on a 12-hour
CLOCK
clock, we will use the symbol ⊖.

Examples:
Calculate using a 12-hour clock

8 ⊕ 10 solution: 6
6⊕7 solution: 1
10 ⊕ 6 solution: 4
5⊖8 solution: 9
3 ⊖ 11 solution: 4
DAY-OF-THE-WEEK
ARITHMETIC
- The same method can be applied to
day-of-the-week arithmetic.
Example:
- If we assign each day of the week
2⊞6=1
with a number, (Monday 1, Tuesday
2, Wednesday 3. Thursday 4, Friday
1 ⊞ 18 = 5
5, Saturday 6, and Sunday = 7 )

- six days after Tuesday is Monday


and 18 days after Monday is Friday
MODULO N
MODULO N

- Let n be a natural number.


- Integers a and b are said to be congruent modulo n if (a - b)/n is
an integer.
- The number n is called the modulus.
- The statement a ≡ b mod n is called a congruence.
MODULO N
Example:
Determine whether the congruence is true

a. 18 ≡ 6 mod 3

b. 23 ≡ 9 mod 4
MODULO N
Example:
Determine whether the congruence is true

a. 18 ≡ 6 mod 3 Solution: Find (a - b)/n = (18 - 6)/3


=4
18 ≡ 6 mod 3 is a true
congruence because 4 is an
Solution:
integer. Find (a - b)/n = (23 - 9)/4
b. 23 ≡ 9 mod 4 = 14/4 = 7/2
23 ≡ 9 mod 4 is not a true
congruence because 7/2 is not an
integer.
THANK YOU
ARITHMETIC
OPERATION
S MODULO N
INSPIRED BY
To evaluate a modular
ARITHME expression, perform the
arithmetic operation and
TIC then divide by the modulus.
OPERATI The answer is the
remainder. The result is
ONS always a whole number less
than modulus .
MODULO
Perform the modular
arithmetic.

Addition Modulo n

a. (9+14) mod 8
Solution: Add 9+14=13. Divide the sum
by the modulus, 8. The remainder is the
answer, which are 5. In symbol, (9+4)
mod 8 = 5.
Perform the modular
arithmetic.

Subtraction Modulo n
b. (22-13) mod 5 Solution: Subtract 22-13=9. Divide the
difference by the modulus, 5. The
remainder is the answer, which are 4. In
symbol, (22-13) mod 5 = 4.

C. (4-15) mod 3 Solution: Subtract 4-15 - 11. Since the result


is negative, find a whole number x less than
the modulus 3, so that - 11 equiv x mod 3.
Thus, we must find x so that the value of, (-
11 - x)/3 is an integer. Trying the number
values of x less than the modulus, we find
that when x = 1 (- 11 - 1)/3 Therefore, (4 -15)
Perform the modular
arithmetic.

Multiplication Modulo n

d. (8 × 13) mod 7 Solution: Multiply 8 * 13 = 104 Divide


the product by the modulus, 7. The
remainder is the answer, which is 6. In
symbol, (813) mod 7 = 6.
SOLVING
CONGRUENCE
EQUATIONS
SOLVING CONGRUENCE
EQUATIONS
Solving a congruence
equation means finding
all values for x that
makes the congruence
true.
xample: Find all the solutions of the congruence
equation.

a. 3x +2 = 5 mod 8 Solution: Substitute the whole numbers less than


the modulus in the congruence equation.

x≠0 3(0) +2 ≠ 5 mod 8 Not a solution


Additional
x=1 3(1) +2 = 5 mod 8x = 1 is a Solution
solutions
x≠2 3(2) +2 ≠ 5 mod 8 Not a solution can be found
by
x≠3 3(3) +2 ≠ 5 mod 8 Not a solution repeatedly
adding the
x≠4 3(4) +2 ≠ 5 mod 8 Not a solution modulus to
x≠5 3(5) +2 ≠ 5 mod 8 Not a solution this solution.
The
x≠6 3(6) +2 ≠ 5 mod 8 Not a solution solutions are
x≠7 3(7) +2 ≠ 5 mod 8 Not a solution 1, 9, 17, ...
Thank you!
Presented by: Sharmaine B.
Cayabyab
Modular additive
inverse
By:Rodalyn
Borja
In modular arithmetic, the modular
additive inverse of x is the number a
such that a + x = 0 mod n. The modular
additive inverse always exists.
Example:
Find the additive inverse of the
following

а.
8 in modulo 13 arithmetic

Solution: The additive inverse is 5 because it is the


solution in a +
8 = 0 mod 13.
EXAPL
E :2
b. 7 in mod 16
arithmetic
Exampl
e :3
C. 3 in mod 11
arithmetic
Modular multiplicative
inverse
Modular Multiplicative Inverse
In modular arithmetic, the modular multiplicative inverse
of xThe sum
is the of 65
number a such that ax 1 mod n. The modular
multiplicative inverse exists it mamber ifa and n are co-
and p
65 + p prime.
EXAMPL
E :2
A.5 in mod 11
arithmetic
B.2 in mod 7
arithmetic
Application of
modular arithmetic
By: Princess Camacho
Jomel Macaraeg
LESSON 2
Applications of Modular Arithmetic
The notion of modular arithmetic is valuable in
verifying the validity of issued numbers. Some
of these are the International Standard
Book Number (ISBN), Universal Product
Code (UPC), Credit Card Numbers, and
many more.
ISBN (International
Standard Book
Number)
By: Princess Camacho
ISBN
• Every book that is catalogued 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
(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 13ᵗʰ one) is called a check digit.
• If we label the first digit of an ISBN
¹ d , the
second
² digit d , and so on to the
¹³ 13ᵗʰ digit d
,then the check digit is given by the
following modular formula.
• Formula for the ISBN check digit:
13-digit ISBN number
• d = 10 – (d + 3d + d + 3d + d + 3d +
¹³ ¹ ² ³ ⁴ ⁵ ⁶ ⁷
d + 3d
⁹ ¹⁰ ¹¹⁸ ¹²
+ d +3d +d +3d ) mod 10
• It is this check digit that is used to ensure
accuracy. For instance, ISBN for the fourth
edition of the America Heritage Directory is
978-0-395-82517-4. However, suppose that
the bookstore clerk sends and order for the
American Heritage Dictionary and
inadvertently enters the number
• Determine whether this is a valid ISBN or
¹³
not.(valid ISBN means that the value of d
and the check digit are the same).
Correct ISBN: 978-0395-82517-4
Incorrect ISBN: 978-0395-28517-4
The receiving clerk calculates the check digit
as follows: (from the Correct ISBN)
d = 10 – (d ¹ + 3d² + d
³ + 3d
⁴ +⁵ d + 3d
⁶ +⁷ d
+ 3d
⁹ ¹⁰ ⁸ ¹¹ ¹²
+¹³d + 3d + d +3d ) mod 10
= 10 – [9 + 3(7) + 8 + 3(0) + 3 + 3(9) + 5 +
3(8) + 2 + 3(5) + 1 +3(7)] mod 10
= 10 – 136 mod 10
= 10 – 6
=4
978-0395-28517-4 (from the Incorrect ISBN)

d = 10 – (d + 3d + d + 3d + d + 3d + d +
3d
¹³ ¹ ² ³ ⁴ ⁵ ⁶ ⁷
+ d⁹ + 3d¹⁰ + d +3d
⁸ ¹¹ ¹² ) mod 10
= 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
• 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 1. Determine a Check Digit for an


ISB. 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-?
Solution
d = 10 – (d + 3d + d + 3d + d + 3d + d
¹³ 3d
+ ¹ ² ³ ⁴ ⁵ ⁶ ⁷
¹⁰ ⁸+ ¹¹
+ d⁹ + 3d d +3d¹² ) mod 10
= 10 – [9 + 3(7) + 8 + 3(0) + 7 + 3(4) + 3 +
3(2) + 5 + 3(8) + 2 +3(0)] mod 10
= 10 – 97 mod 10
= 10 – 7
=3
Thus, the check digit is 3
UPC
(Universal
Product Code)
By: Jomel Macaraeg
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.
• 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.
• 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
d , d , d ,…, d , we can write a formula
¹² for
the UPC check digit d .
• Formula for the UPC Check Digit
• ¹²
d = 10 – (3d¹ + ² d + ³3d + ⁴ d +⁵ 3d ⁶+ d +⁷
3d + d ⁸
⁹ ¹⁰ ¹¹
+ 3d + d + 3d ) mod 10
Example 2. Determine the Check Digit of a UPC
Find the check digit for the UPC of the Blu-ray Disc
release of the film Jurassic World given the first 11
digits are 0-25192-21221-?.
Solution
d¹² = 10 – (3d
¹ +² d + 3d ³ +⁴ d + ⁵3d +⁶ d +⁷3d + d
+ 3d⁹ + d
¹⁰ ⁸+ 3d
¹¹ ) mod 10
= 10 – [3(0) + 2 + 3(5) + 1 + 3(9) + 2 + 3(2) + 1
+ 3(2) + 2 + 3(1)] mod 10
= 10 – 65 mod 10
= 10 – 5
=5
Determine whether 1-10203-21042-4 a valid
UPC?
Solution:
d¹² = 10 – (3d
¹ +² d + 3d³ +⁴ d + 3d
⁵ +⁶ d + ⁷3d
+d ⁸
⁹ ¹⁰ ¹¹
+ 3d + d + 3d ) mod 10
=10 - [3(1) + 1 + 3(0) + 2 + 3(0) + 3 + 3(2) +
1 + 3(0) + 4 + 3(2)]
= 10 – 26 mod 10
= 10 – 6
= 4 Since the check digit is 4, the UPC is
valid.
THANK YOU FOR LISTENING!
INSPIRED BY

Credit
Card
Numbers
By: Pascual,Isabelle G.
A credit card number is typically
16 digits in length, often
appearing in sets of four. It is used
to identify both the credit card
issuer and the account holder.
Credit card numbers are not
random. It can be tested by a
modular formula for validity.
The Luhn algorithm (also called mod 10)
is a checksum formula used to
determine whether a credit card
number is valid. It is calculated as
follows: Starting from the rightmost
digit double the value of every second
digit. If the results become a two-digit
number, treat the number as two
individual digits. Now find the sum of all
the digits. If the modulo 10 is equal to
Example:
Determine whether 5234-8213-3410-1825
is a valid credit card number.
Solution
:5 2 3 4 8 2 1 3 3 4 1 0 1
Starting from the8 rightmost
35 digit double the value of every
second digit.
10 2 6 4 16 2 2 3 6 4 2 0 2 8
Then, find the sum6of
5 all the digits.
1+0+2+6+4+1+6+2+2+3+6+4+2+0+2+8
nce 60 = 0 mod 10, this is+a6valid
+ 5 =credit
60 card number.
Cryptography is the art of
writing and solving secret codes.
The word comes from the Greek
words, kryptos, meaning hidden
and graphien,meaning writing.
CRYPTOGRAPHY
The key terms in cryptography
are listed below.
a. Plaintext is a clear-text
message before it is coded.
Example:

MATHEMATICAL SYSTEM
(Start from the letter "A" when the
b. Ciphertext is the
end of the English alpha- bet is
message after it has reached.) This is called cyclical
been written in code. coding scheme because each letter
of the English alphabet is shifted
Example: the same number of positions. The
English alphabet and the substitute
ESLZWESLAUSD KQKLWE
alphabet are shown below.
c. Encryption is the
process of converting
plaintext to ciphertext.
The word "MATHEMATICAL SYSTEM" d. Decryption is the
was encrypted by substituting each process of reverting
letter in plaintext with the letter that ciphertext to plaintext.
is 18 letters after that letter in the
alphabet.
If a message has been encrypted The key to the code can be
using a cyclical substitution code, the determined when a recognizable
key to the code can be determined word appears. In this case, the word
by taking a word from the encrypted "MATHEMATICAL" appeared after the
message and continuing the letters have been shifted eight times.
alphabet for each letter of the word. Substitute the letter of the English
ESLZWESLAUSD alphabet that comes eight positions
FTMAXFTMBVTE after the letter in the encrypted
GUNBYGUNCWUF message to decode the message.
Encrypted Message: Decrypted
HVOCZHVODXVG ESLZWESLAUSD KQKLWE Message:
IWPDAI WPEYWH Shift 8 MATHEMATICAL
Shift Eight Positions
SYSTEM
JXQEBJXQFZXI
Cyclical coding scheme using the
KYRFCKYRGAYJ English alphabet is related to
LZSGDLZSHBZK modular arithmetic. They start with
MATHEMATICAL the English alphabet and assign each
letter with a number as shown below.
≡p (c + n) mod 26
where: p = the numerical equivalent of the plaintext
letter
c = the numerical equivalent of the ciphertext
letter
n = 26-m
Example:
m = the number of positions the letter is shifte
If the encrypting code is to shift each
letter of the plaintext message m Use the cyclical alphabetic
positions, then the corresponding letter encrypting code that shifts
in the ciphertext message is given by
c (p
≡ + m) mod 26 each letter 8 position to:
here: c = the numerical equivalent of the ciphertext letter
p = the numerical equivalent of the plaintext letter
m = the number of positions the letter is to a. code MATH IS FUN.
shifted
There is also a method by which the
person receiving the message can
return the encrypted message to
plaintext. For the cyclical code, the
Solution;

The coded message is UIBP QA NCV.


b. Decode NQAP
Solution;

The coded message is FISH.


A coding scheme that is 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.


p = the numerical equivalent of the plaintext
letter
c = the numerical equivalent of the ciphertext
letter
m = the number of positions the letter is
shifted
Example;

Use the congruenc≡c (3p + 10) mod 26 to


encode the message MODERN.

The coded message is


Decoding a message that was encrypted using the
congruence
≡ c (ap + m) mod 26 requires solving
the congruence for p. Here we solve the congruence
used in the last:
Example for p.

c = 3p + 10
c - 10 = 3p * Subtract 10 from both side of the
9(c - 10) = equation.
9(3p) ≡
* Multiply both side of the equation by
the mul- tiplicative inverse of 3. Since 9
•3 1 mod 26, multiply both side by 9.
[9(c - 10)] mod ≡26 p
We can now convert the ciphertext message
WCVYLZ to plaintext using the congruence
26≡ p
equation [9(c - 10)] mod
. The method for decoding the ciphertext is
shown in the table below.
THANK YOU FOR
YOUR
ATTENTION !

You might also like