










Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!











ACM C’EPT
− 1
We can notice that : 𝑥 𝑛 = 𝑥 𝑛 Τ 2 ∗ 𝑥 𝑛Τ 2 if n is even 𝑥 𝑛 = 𝑥 ∗ 𝑥 𝑛− 1 Τ 2 ∗ 𝑥 𝑛− 1 Τ 2 if n is odd
So the optimized algorithm is:
To compute this, we use two functions, to simplify the algorithm: And so, the final function is : Modular binary exponentiation Modular multiplication
However, there is a better way to compute prime numbers. Let’s consider the following table
So let’s see the algorithm for the Sieve of Erastothenes :