next up previous
Next: Finding large numbers that Up: Lecture 7: Congruences, Part Previous: How to Compute Efficiently

A Probabilistic Primality Test

Recall,

Theorem 3.1   A natural number $ p$ is prime if and only if for every $ a\not\equiv 0\pmod{p}$,

$\displaystyle a^{p-1}\equiv 1\pmod{p}.
$

Thus if $ p\in\mathbb{N}$ and, e.g., $ 2^{p-1}\not\equiv 1\pmod{p}$, then we have proved that $ p$ is not prime. If, however, $ a^{p-1}\equiv 1\pmod{p}$ for a couple of $ a$, then it is ``highly likely'' that $ p$ is prime. I will not analyze this probability here, but we might later in this course.

Example 3.2   Let $ p=323$. Is $ p$ prime? Let's compute $ 2^{322}$ modulo $ 323$. Making a table as above, we have
    $ i$             $ m$              $ \varepsilon _i$             $ 2^{2^i}$ mod 323
0 322 0 2
1 161 1 4
2 80 0 16
3 40 0 256
4 20 0 290
5 10 0 120
6 5 1 188
7 2 0 137
8 1 1 35
Thus

$\displaystyle 2^{322} \equiv 4\cdot 188\cdot 35 \equiv 157\pmod{323},$

so $ 323$ is not prime. In fact, $ 323 = 17\cdot 19$.

It's possible to prove that a large number is composite, but yet be unable to (easily) find a factorization! For example if

$\displaystyle n = 95468093486093450983409583409850934850938459083,$

then $ 2^{n-1}\not\equiv 1\pmod{n}$, so $ n$ is composite. This is something one could verify in a reasonable amount of time by hand. (Though finding a factorization by hand would be very difficult!)



Subsections
next up previous
Next: Finding large numbers that Up: Lecture 7: Congruences, Part Previous: How to Compute Efficiently
William A Stein 2001-09-25