Professional Documents
Culture Documents
Fast Modular Exponentiation Example
Fast Modular Exponentiation Example
To compute 103−97 , we must first compute 103−1 , and for this, we make use of the following result.
Theorem 1. Fermat’s little theorem If p is a prime number, then for any integer a,
ap−1 = 1 mod p.
Therefore,
ap−2 = a−1 mod p.
2
1032 = (1032 )2 = 1292 = 4 mod 131
23
103 = (103 ) =
4 2
4 =
2
16 mod 131
24
103 = (103 ) =
8 2
16 =
2
125 mod 131
25
103 = (103 ) =
16 2
125 =2
36 mod 131
Thus,
5
10333 = 103 × 1032 = 103 × 36 = 40 mod 131.
That is, 103−97 = 40 mod 131.
Finally,