


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
These notes cover the concepts of modular exponentiation and euler's function, including the repeated squaring method for efficient computation of powers in modular arithmetic, and the definition and properties of euler's function. The document also includes exercises for practicing these concepts.
Typology: Study notes
1 / 4
This page cannot be seen from the preview
Don't miss anything!



There are problems to be turned in (all starred) at the end of this docu- ment.
Basic Fact: ax^ ≡ (amodn)xmodn (you can replace the base in an exponen- tiation by its remainder mod n if you are working in mod n arithmetic). But ax^ is not necessarily congruent to axmodn^ modulo n: for example, 3 is equivalent to 13 in mod 10 arithmetic, but 7^3 = 343 is not equivalent to 713 = 96889010407: the first is equivalent to 3 mod 10 while the second is equivalent to 7. Repeated Squaring: A technique which allows efficient computation of powers in modular arithmetic (though not nearly as efficient as the method using Euler’s function below) is the method of repeated squaring. To compute ax^ mod n, note that the exponent x is either even or odd. If x = 2k is even, then ax^ = a^2 k^ = (ak)^2 : compute ak^ then square it. If x = 2k + 1 is odd, then ax^ = a^2 k+1^ = a^2 k^ · a = (ak)^2 · a. Either way, we compute the square of axdiv2^ and multiply by axmod2^ (the latter being either 1 or a). We give an example: Compute 7^330 mod 13. The powers of 7 that we need to compute are obtained by dividing 330 by 2 repreatedly (throwing away remainders): 330, 165, 82, 41, 20, 10, 5, 2, 1 71 = 7 mod 13
72 = 7 · 7 = 49 = 10 mod 13 75 = (7^2 )^2 · 7 = 10^2 · 7 = 11 mod 13 710 = (7^5 )^2 = 11^2 = 121 = 4 mod 13 720 = (7^1 0)^2 = 4^2 = 16 = 3 mod 13 741 = (7^20 )^2 · 7 = 3^2 · 7 = 63 = 11 mod 13 782 = (7^41 )^2 = 11^2 = 121 = 4 mod 13 7165 = (7^82 )^2 · 7 = 4^2 · 7 = 8 mod 13 7330 = (7^165 )^2 = 8^2 = 64 = 12 mod 13 so the answer is 12. To compute 7^330 the naive way would take 329 multiplications; in general, ax^ would take x − 1 multiplications. The method of repeated squaring takes (roughly speaking) 1 or 2 multiplications for each power of two below x: the number of multiplications needed is at most 2 · dlog 2 (x)e. Here we needed 11 multiplications.
2 Euler’s Function
For any positive integer n we define φ(n) as the number of positive integers a < n such that a is relatively prime to n. First Fact: φ(p) = p − 1 if p is a prime. In this case, the positive integers less than p which are relatively prime to p are all of them: 1, 2 ,... , p − 1 are a total of p − 1 positive integers less than p which are relatively prime to p. Second Fact: φ(pn) = pn^ − pn−^1 for p a prime. There are pn^ − 1 positive integers less than pn. Of these, only the multiples of p are not relatively prime to pn, and there are pn−^1 − 1 of these. So there are (pn^ − 1) − (pn−^1 − 1) = pn^ − pn−^1 positive integers less than pn^ which are relatively prime to pn. Third Fact: If m and n are relatively prime, then φ(mn) = φ(m)φ(n). There are exactly as many natural numbers less than mn as there are systems of equations x = a mod m x = b mod n with 0 ≤ a < m and 0 ≤ b < n, because by the Chinese Remainder Theorem each of these mn equations has a unique solution mod mn.
We also might have to use repeated squaring if we do not know the prime factorization of n, since our ability to compute φ(n) depends on being able to factor n. Example of calculation of a power by this method: Compute 1243542535^23415675437654 mod 18. φ(18) = φ(2 · 32 ) = (2 − 1) · (3^2 − 31 ) = 6 1243542535 mod 18 = 7 23415675437654 mod 6 = 2 so 1243542535^23415675437654 = 7^2 = 49 = 13 mod 18.
4 Exercises
φ(37), φ(125), φ(45), φ(144), φ(143), φ(300)