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

ModularArithmetic_MathsUnboxed_Handout

The document provides an introduction to modular arithmetic, including its formal definition and useful properties. It includes examples demonstrating how to use modular arithmetic to solve problems and introduces the RSA algorithm for secure message transmission. Additionally, it offers further topics for exploration related to modular arithmetic.

Uploaded by

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

ModularArithmetic_MathsUnboxed_Handout

The document provides an introduction to modular arithmetic, including its formal definition and useful properties. It includes examples demonstrating how to use modular arithmetic to solve problems and introduces the RSA algorithm for secure message transmission. Additionally, it offers further topics for exploration related to modular arithmetic.

Uploaded by

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

Modular Arithmetic www.youtube.

com/mathsunboxed
www.instagram.com/maths_unboxed
Introduction [email protected]
Different ways to think about modular arithmetic: What is 5 (mod 3)?

Formal definition: x ≡ a (mod n) if x - a is divisible by n eg. 5 ≡ 2 (mod 3) means that 5 – 2 is divisible by 3

Useful property: If x ≡ a (mod n) and y ≡ b (mod n) then: 1. x + y ≡ a + b (mod n) 2. xy ≡ ab (mod n)


Proof of 1:
• SECRET AIM: Show that (x+y) – (a+b) is divisible by n (result then follows using the formal definition)
• Have x ≡ a (mod n) so x - a is divisible by n (using the formal definition).
• That is, x – a = kn for some integer k.
• Similarly, y ≡ b (mod n) so y - b is divisible n and so y - b = rn for some integer r
• Then: (x+y) – (a+b) = (x-a) + (y-b) = kn – rn = n(k-r)
• So (x+y)-(a+b) is divisible by n, that is x+y ≡ a+b (mod n) as required J

Proof of 2:
Try this for yourself first by adapting the proof above! If you get stuck, the proof is at the bottom of the next page.

Examples of using Modular Arithmetic: (There are video explanations to these on my YouTube channel)
1. What is the final digit of 7100?
• This is the same as asking “what is 7100 mod 10?”. Have a think about why!
• Note that 7100 = 7 x 7 x 7 x ……. x 7. We want to use Useful Property 2 to help, but 7 is already reduced under
modulo 10. 100 times

• However, we can group the 7’s into pairs: 7 x 7 x 7 x ……. x 7 = 72 x 72 x … x 72 = 49 x 49 x …… x 49


100 times 50 times 50 times
• Normally we say that 49 ≡ 9 (mod 10). But it’s also true that 49 ≡ -1 (mod 10) (make sure you see why)
• So we have that 7100 = 49 x 49 x …… x 49 ≡ (-1) x (-1) x … x (-1) (mod 10)
50 times 50 times
• But an even product of -1’s is just 1. So 7100 ≡ 1 (mod 10) so the final digit of 7100 is 1.

2. Can 4003 be written as the sum of two square numbers?


• We prove it can’t by using proof by contradiction. Suppose it can, say 4003 = x2 + y2 where x and y are integers.
• Note that 4003 ≡ 3 (mod 4). So we have that x2 + y2 ≡ 3 (mod 4). ❖
• x and y are each congruent to one of 0, 1, 2 or 3 (mod 4). (every number is congruent to one of these mod 4).
• So x2 and y2 are each congruent to one of 02, 12, 22, 32 (mod 4).
• Note in mod 4: 02 = 0, 12 = 1, 22 = 4 ≡ 0, 32 = 9 ≡ 1. So x2 and y2 can each either be congruent to 0 or 1 (mod 4).
• So x2 + y2 cannot be congruent to 3 (mod 4) (as no combination of two of 0’s and 1’s add to 3).
• But this is a contradiction with ❖. Hence 4003 cannot be written as the sum of two square numbers.
More questions to try: (you can check your answers to 1&2 using
the website WolframAlpha) www.youtube.com/mathsunboxed
1. What is 399 mod 5?
2. What is the remainder when 20202020 is divided by 3? (note: this is the same as asking “what is
20202020 (mod 3)?”. Have a think about why!)
3. Prove, using modular arithmetic, that there is no square number that is a multiple of 2 but not a
multiple of 4. (Hint: Use proof by contradiction. If there is such a number x, what is x (mod 4)?
What values can square numbers take in modulo 4?)

How to send secret messages using Modular Arithmetic (the RSA algorithm)
Say you are Person A and you want Person B to send you a top secret A B C D E F G H I
message that can’t be decoded if it is intercepted by someone else.
1 2 3 4 5 6 7 8 9
Person A
1. Choose 2 distinct prime numbers p, q (each greater than 40 and less than 200)
2. Calculate n = p x q
3. Calculate t = (p-1)(q-1)
4. Choose a prime number e such that the highest common factor of e and t is 1.
5. On the website WolframAlpha search “What is the multiplicative inverse of e modulo t?”. Call the result
d. (your search on WolframAlpha has found the multiplicative inverse of e (mod t) which is the number d such
that ed ≡ 1 (mod t). Search up ‘multiplicative inverses modular arithmetic’ for more information on these
numbers. If you’re interested in how WolframAlpha calculates this, search up the ‘Euclidean Algorithm’.
6. Give Person B the values of n and e – in fact everyone can see this! Even the people who you don’t want
to read your future message can get these values; these values won’t help them!
Person B
1. Choose a message that is 3 letters long using the letters A through to I. (you can send longer messages if
you send them in 3 letter chunks. You can also use different letters if you create a table assigning 9 letters of
your choice the numbers 1-9.)
2. Convert your message into numbers using the yellow table above. This is M. Eg. If your message is ‘CAB’
then M = 312.
3. Calculate Me (mod n) using WolframAlpha (type in the search bar “M^e (mod n)”). Label this number C.
4. Give C to Person A – this is your encrypted message!
Person A
1. Compute Cd (mod n) using WolframAlpha. Convert this to letters using the table to receive the message!
Note, that even if someone intercepted the message C when it passed from Person B to Person A, they would be
unable to decrypt it as they don’t have the value d, and they can’t work it out from the values n and e (if they have
these) due to how hard it is factor numbers if they are a product of two large primes.
This is the method that most computers and large companies use to encrypt and decrypt information securely –
except normally they choose p and q to be of over 1000 digits in length!

Further interesting things you can search up:


• Fermat’s Little Theorem • Wilson’s Theorem
• Multiplicative inverses in modular arithmetic • The Chinese Remainder Theorem

Proof of Useful Property 2:


• SECRET AIM: Show that xy – ab is divisible by n
• Have x ≡ a (mod n) so x - a = kn for some integer
• y ≡ b (mod n) so y - b = rn for some integer r
• Then: xy – ab = (kn+a)(rn+b) - ab = (krn2 + arn +bkn + ab) – ab = krn2 + arn + bkn = n(krn + ar +bk)
• So xy - ab is divisible by n, that is xy ≡ ab (mod n) as required (using the formal definition) J

You might also like