Basic Mathematics
Outline
Fermat's Little Theorem,
Euler Totient Function ,
Euler's Theorem
Chinese Remainder Theorem
Chinese Remainder Theorem
The child of a number theorist is sorting a large pile of pennies (worth less than a dollar)
into groups of 3 pennies each. At the end, the child reports that 2 pennies are left over.
The child starts over, instead sorting the pennies into groups of 4 and reports that 1 penny
is left over. The child starts over again, sorting the pennies into groups of 11 and reports
that 7 pennies are left over. The number theorist didn’t originally know how many pennies
were in the pile, but at this point she speaks up.
What does she say? Did the child make a mistake in sorting the pennies? Or does the
number theorist have enough information to tell how many pennies are in the pile?
The Chinese remainder theorem(CRT)
The Chinese Remainder Theorem (CRT) is a fundamental theorem in number theory with various applications,
including cryptography and computer science. It states that if you have a set of simultaneous congruences,
each modulo a different prime power, and the moduli are pairwise coprime (i.e., their greatest common
divisor is 1), then there exists a unique solution modulo the product of all the moduli as shown below:
X ≡ a1 ( mod m1)
X ≡ a2 ( mod m2)
X ≡ a3 ( mod m3)
.
X ≡ an ( mod mn)
X = (a1M1M-1 + a2M2M-2 + a3M3M-3 …………… anMnM-n ) mod M
Where m1, m2…..mn are pairwise coprime, then there exists a unique solution for x modulo M =
m1x m2x…..mn
Solution
X = (a1M1M-1 + a2M2M-2 + a3M3M-3 …………… anMnM-n ) mod M
a1,a2,..an are given in the equation.
Example 1: Solve the following equations using CRT
X ≡ 2 (mod 3)
X ≡ 3 (mod 5)
X ≡ 2 (mod 7)
X = (a1M1M-1 + a2M2M-2 + a3M3M-3)
X ≡ 2 (mod 3) X ≡ a1 ( mod m1)
X ≡ 3 (mod 5) X ≡ a2 ( mod m2)
X ≡ 2 (mod 7) X ≡ a3 ( mod m3)
X = (a1M1M-1 + a2M2M-2 + a3M3M-3)
Given To find
a1=2 m1=3 M1 M-1
M
a2=3 m2=5 M2 M-2
a3=2 m3=7 M3 M-3
M=m1 x m2 x m3 M=3x5x7, M=105
M1=M/m1 M1=105/3, M1=35
M2=M/m2 M2=105/5, M2=21
M3=M/m3 M3=105/7, M3=15
Given To find
a1=2 m1=3 M1=35 M-1
a2=3 m2=5 M2=21 M-2 M=105
a3=2 m3=7 M3=15 M-3
M1 x M-1 = 1 mod m1 M2 x M-2 = 1 mod m2 M3 x M-3 = 1 mod m3
35 x M-1 = 1 mod 3 31 x M-2 = 1 mod 5 15 x M-3 = 1 mod 7
1. Try all possible number 1. Try all possible number 1. Try all possible number
2. Extended Euclidean algorithm 2. Extended Euclidean algorithm 2. Extended Euclidean algorithm
35 x 2 = 1 mod 3 31 x 1 = 1 mod 5 15 x 1= 1 mod 7
M-1 = 2 M-2 = 1 M-3 = 1
X = (a1M1M-1 + a2M2M-2 + a3M3M-3)
X = (2x35x2 + 3x21x1 + 2x15x1)
X = 233 mod 105
X = 23
Example
Example 1: Solve the following equations using CRT
X ≡ 2 (mod 3)
X ≡ 1 (mod 4)
X ≡ 7 (mod 11)
X = 29
Fermat's Little Theorem
Fermat’s little theorem states that if p is a prime number, then for any integer a, the number
a(p – a) is an integer multiple of p.
Here p is a prime number
• ap-1 ≡ 1 (mod p).
This theorem helps to solve so many cryptographic problem.
If a is not divisible by p, Fermat’s little theorem is equivalent to the statement that a (p-1)-1 is
an integer multiple of p
ap-1 ≡ 1 (mod p)
OR
ap-1 % p = 1
Here a is not divisible by p.
Example 1
P = an integer Prime number
a = an integer which is not a multiple of P
Let a = 2 and P = 17
According to Fermat's little theorem
2(17 – 1) ≡ 1 mod(17)
we got 65536 % 17 ≡ 1
that mean (65536-1) is a multiple of 17
Does Fermat’s theorem hold true for p=5 and a=2?
Does Fermat’s theorem hold true for p=13 and a=11?
ap-1 ≡ 1 (mod 13)
1113-1 ≡ 1 (mod 13)
1112 ≡ 1 (mod 13)
-212 ≡ 1 (mod 13)[11-13=-2]
-24x3 ≡ 1 (mod 13)[-24 mod 13]
33 ≡ 1 (mod 13)
27 ≡ 1 (mod 13)
Does Fermat’s theorem does not hold true for p=6 and a=2?
Does Fermat’s theorem does not hold true for p=11 and a=5?
Euler’s theorem
For every positive integer ‘a’ and ‘n’ which are said to be relative prime, then
aɸ(n) ≡ 1 (mod n)
ɸ(n) is the Euler’s totients function
1. Prove Euler’s theorem holds true for a=3 and n=10
ɸ(n)= number of positive integers less than ‘n’ that are relatively prime to n.
ɸ(5): ?
Numbers less than 5: 1,2,3 and 4
How many of these are relative prime to 5
GCD Relative prime?
GCD(1,5)=1 Yes
GCD(2,5)=1 Yes
GCD(3,5)=1 Yes
GCD(4,5)=1 Yes
So, there are 4 number less than 5 are relative prime to 5:
ɸ(5): 4
ɸ(11): ?
Numbers less than 11: 1,2,3,4,5,6,7,8,9 and 10
How many of these are relative prime to 5
GCD Relative prime? GCD Relative prime?
GCD(1,11)=1 Yes GCD(6,11)=1 Yes
GCD(2,11)=1 Yes GCD(7,11)=1 Yes
GCD(3,11)=1 Yes GCD(8,11)=1 Yes
GCD(4,11)=1 Yes GCD(9,11)=1 Yes
GCD(5,11)=1 Yes GCD(10,11)=1 Yes
So, there are 4 number less than 5 are relative prime to 5:
ɸ(5): 4
ɸ(8): ?
Numbers less than 8: 1,2,3,4,5,6 and 7
How many of these are relative prime to 5
GCD Relative prime? GCD Relative prime?
GCD(1,8)=1 Yes GCD(6,8)=2 No
GCD(2,8)=2 No GCD(7,8)=1 Yes
GCD(3,8)=1 Yes
GCD(4,8)=4 No
GCD(5,8)=1 Yes
So, there are 4 number less than 8 are relative prime to 8:
ɸ(5): 4
Prove Euler’s theorem holds true for a=3 and n=10
Given a=3, n=10
3ɸ(10) ≡ 1 (mod 10)
ɸ(10)=4
34 ≡ 1 (mod 10)
81 ≡ 1 (mod 10)
True
Does Euler’s theorem holds true for a=2 and n=10?