Docsity

Modular Arithmetic and Prime Numbers: ACM C’EPT Lecture Notes, Cheat Sheet of Mathematics

Partial preview of the text

Download Modular Arithmetic and Prime Numbers: ACM C’EPT Lecture Notes and more Cheat Sheet Mathematics in PDF only on Docsity!

NUMBER THEORY

ACM C’EPT

Introduction

I. Modular Arithmetic

− 1

1. Modular operations

We can notice that : 𝑥 𝑛 = 𝑥 𝑛 Τ 2 ∗ 𝑥 𝑛Τ 2 if n is even 𝑥 𝑛 = 𝑥 ∗ 𝑥 𝑛− 1 Τ 2 ∗ 𝑥 𝑛− 1 Τ 2 if n is odd

Complexity :

O(log(n)) ✓

So the optimized algorithm is:

II. Modular Inverse

To compute this, we use two functions, to simplify the algorithm: And so, the final function is : Modular binary exponentiation Modular multiplication

III. GCD, LCM

Exemple :

IV. Prime Numbers

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 :