Created
June 5, 2022 09:29
-
-
Save igorvanloo/5b50b95fbaf5343da6870677223cc49d to your computer and use it in GitHub Desktop.
Fermat Primality Test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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