Should you use Euler's generalization of fermat's little theorem for primality testing?

111 Views Asked by At

The title is a bit long, but i think it explains my question well.

Let's say we want to test if an integer p is prime

With Fermat's Little Theorem this is a simple check if

$a^{p-1} \equiv 1 (mod \ p)$

But using the Euler's version:

If $gcd(a,n) = 1, $ then $\ a^{\Phi(n)} \equiv 1 (mod\ n)$

Can we say with a high probability that n is a prime in this case?

2

There are 2 best solutions below

3
On BEST ANSWER

We cannot say that $n$ is prime, given $a^{n-1}\equiv 1 \bmod n$; see Carmichael numbers:

Understanding Carmichael Number

Fermat primality test $\gcd$ condition and carmichael numbers

0
On

Fermat's little theorem does not guarantee p is prime. What will, as you can see if you find it in the linked page, is Lehmer's theorem. Euler's theorem is nearly pointless.