Modular Arithmetic and Primality
Modular Arithmetic and Primality
Modular Arithmetic and Primality
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
function primality(N)<br />
Input: Positive integer N<br />
Output: maybe/no<br />
// a is r<strong>and</strong>om positive integer between 2 <strong>and</strong> N-1<br />
a = uniform(2 … N-1)<br />
if (modexp(a, N-1, N) == 1): return maybe a prime<br />
else: return no<br />
CS 312 - Complexity Examples - <strong>Arithmetic</strong> <strong>and</strong> RSA 30