Skip to content

Instantly share code, notes, and snippets.

@igorvanloo
Created June 5, 2022 09:29
Show Gist options
  • Save igorvanloo/5b50b95fbaf5343da6870677223cc49d to your computer and use it in GitHub Desktop.
Save igorvanloo/5b50b95fbaf5343da6870677223cc49d to your computer and use it in GitHub Desktop.
Fermat Primality Test
def fermat_primality_test(n, tests):
for x in range(tests):
if pow(2*(x + 2), n - 1, n) != 1:
return False
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment