#! /usr/bin/python

from mod import ZMod

def isPrime(n):
    '''isPrime(n) returns True if n passes the Fermat test for a = 2..20,
    and False otherwise.  Failing the test proves n composite, while passing
    it only gives a high probability that n is prime, except when n happens
    to be a Carmichael number.'''

    ModN = ZMod(n)
    for a in range(2,20):
       if ModN(a)**(n-1) != 1:
            print a
            return False
    return True
