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

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

2023/2024

Uploaded on 03/21/2024

hedi-ksentini-1
hedi-ksentini-1 🇹🇳

1 document

1 / 18

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
NUMBER THEORY
ACM C’EPT
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12

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 :