1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| def fermat(number, count): """ Used Fermat's Little Theorem to test if a number is prime Args: number: int count: int return: bool """ for i in range(count): while True: a = random.randint(1, number - 1) if math.gcd(a, number) == 1: break if pow(a, number - 1, number) != 1: return False return True
|