Fermat primality test
The Fermat primality test is a probabilistic method used to determine if a number is prime. It is based on Fermat's Little Theorem, which states that if p is a prime number and a is an integer not divisible by p , then a^(p-1) \equiv 1 \mod p . If a number fails this test for a chosen base a , it is definitely composite.
However, if a number passes the test, it is not guaranteed to be prime; it could be a Carmichael number, which can mislead the test. To increase accuracy, the test is often repeated with different bases.