










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
An in-depth exploration of modular arithmetic, modular inverse, gcd, lcm, and prime numbers. It includes formulas, algorithms, and examples for modular operations, modular exponentiation, computing the modular inverse using fermat’s little theorem, and the euclidean algorithm for gcd. Additionally, it discusses a greedy method and the sieve of eratosthenes for testing prime numbers. Useful for university students studying computer science, particularly those focusing on algorithms and number theory.
Typology: Cheat Sheet
1 / 18
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 :