Skip to content

Instantly share code, notes, and snippets.

@airicbear
Last active March 21, 2021 00:58
Show Gist options
  • Save airicbear/efaaa27cfb6e3f3a0f80edffb983c67f to your computer and use it in GitHub Desktop.
Save airicbear/efaaa27cfb6e3f3a0f80edffb983c67f to your computer and use it in GitHub Desktop.
Fermat's little theorem for testing primality
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