You are on page 1of 32

Congruence

Additive and Multiplicative Inverse


• Additive Inverse:
• 𝑥 + 𝑦 ≡ 0 (𝑚𝑜𝑑 𝑚)

• Multiplicative Inverse:
• 𝑥 ∗ 𝑦 ≡ 1 (𝑚𝑜𝑑 𝑚)
Multiplicative inverse using extended
euclidean algorithm
• Use the Extended Euclidean Algorithm with a=n and b
• Do not write down the s-columns
• Continue until r=0.
• Column b on the last row will be gcd(n, b).
• If gcd(n, b) = 1, then we need the value of t2.
• Multiplicative inverse = t2 mod n
Example
• Find multiplicative inverse of 11 in Z26.

n b q r t1 t2 t
26 11 2 4 0 1 -2
11 4 2 3 1 -2 5
4 3 2 1 -2 5 -7
3 1 3 0 5 -7 26

• t2 mod n = (-7) mod 26 = 19


Primes

A prime is divisible only by itself and 1.


Examples of primes

• What is the smallest prime?

The smallest prime is 2, which is divisible by 2 (itself) and 1.

• List the primes smaller than 10.

There are four primes less than 10: 2, 3, 5, and 7.


Cardinality of primes
• Infinite number of primes

There is an infinite number of primes.

• Number of primes
Checking for primeness
Given a number n, how can we determine if n is a prime? The answer is that we need to see if the
number is divisible by all primes less than √𝑛

• Is 97 a prime?
The floor of 97 = 9. The primes less than 9 are 2, 3, 5, and 7. See if 97 is divisible by any of these
numbers. So 97 is a prime.

• Is 301 a prime?

The floor of 301 = 17. We need to check 2, 3, 5, 7, 11, 13, and 17. The numbers 2, 3, and 5 do not
divide 301, but 7 does. Therefore 301 is not a prime.
Sieve of Eratosthenes
Euler’s Phi-Function

9.10
Continued

We can combine the above four rules to find the value of


f(n). For example, if n can be factored as
n = p1e × p2e × … × pke
1 2 k

then we combine the third and the fourth rule to find

9.11
Continued

• What is the value of f(13)?

Because 13 is a prime, f(13) = (13 −1) = 12.

• What is the value of f(10)?

We can use the third rule: f(10) = f(2) × f(5) = 1 × 4 = 4, because 2


and 5 are primes.

9.12
Continued

• What is the value of f(240)?

We can write 240 = 24 × 31 × 51. Then

f(240) = (24 −23) × (31 − 30) × (51 − 50) = 64

• Can we say that f(49) = f(7) × f(7) = 6 × 6 = 36?

No. The third rule applies when m and n are relatively prime.
Here 49 = 72. We need to use the fourth rule: f(49) = 72 − 71 = 42.
9.13
Fermat’s Little Theorem

First Version

ap − 1 ≡ 1 mod p

Second Version

ap ≡ a mod p

9.14
Continued

• Find the result of 610 mod 11.

We have 610 mod 11 = 1. This is the first version of Fermat’s little


theorem where p = 11.

• Find the result of 312 mod 11.

Here the exponent (12) and the modulus (11) are not the same.
With substitution this can be solved using Fermat’s little theorem.

9.15
Continued

Multiplicative Inverses

a−1 mod p = a p − 2 mod p

The answers to multiplicative inverses modulo a prime can be


found without using the extended Euclidean algorithm:

9.16
Euler’s Theorem

First Version

af(n) ≡ 1 (mod n)
Second Version

a k × f(n) + 1 ≡ a (mod n)

9.17
Continued

• Find the result of 624 mod 35.

624 mod 35 = 6f(35) mod 35 = 1.

• Find the result of 2062 mod 77.

If we let k = 1 on the second version, we have


2062 mod 77 = (20 mod 77) (20f(77) + 1 mod 77) mod 77
= (20)(20) mod 77 = 15.
9.18
Continued

Multiplicative Inverses

a−1 mod n = af(n)−1 mod n


The answers to multiplicative inverses modulo a composite can be
found without using the extended Euclidean algorithm if we know
the factorization of the composite:

9.19
Generating Primes – Mersenne Primes
Generating Primes – Fermat Primes

F0 = 3 F1 = 5 F2 = 17 F3 = 257 F4 = 65537
F5 = 4294967297 = 641 × 6700417 Not a prime
Factorization
Fundamental Theorem of Arithmetic

Greatest Common Divisor

Least Common Multiplier


Factorization Methods
Trial division method
Fermat method
Pollard p-1 method
Pollard rho model
Contd.
Chinese Remainder Theorem

Solution To Chinese Remainder Theorem

1. Find M = m1 × m2 × … × mk. This is the common modulus.


2. Find M1 = M/m1, M2 = M/m2, …, Mk = M/mk.
3. Find the multiplicative inverse of M1, M2, …, Mk using the
corresponding moduli (m1, m2, …, mk).
4. The solution to the simultaneous equations is
Examples
Example
• Find an integer that has a remainder of 3 when divided by 7 and 13, but is divisible by 12.

If we follow the four steps, we find x = 276.

You might also like