Last active
March 21, 2021 00:58
-
-
Save airicbear/efaaa27cfb6e3f3a0f80edffb983c67f to your computer and use it in GitHub Desktop.
Fermat's little theorem for testing primality
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
function isprime(N) | |
if N < 2 | |
return false | |
end | |
a = rand(1:(N - 1)) | |
return powermod(a, N - 1, N) == 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment