Last active
November 10, 2018 16:31
-
-
Save en0/2e71dba8d186cc541d96b119cd3436b0 to your computer and use it in GitHub Desktop.
O(1) Prime test
This file contains 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 is_prime(p): | |
"""Not Perfect - Do not use.""" | |
if p > 2: | |
return ((2**(p-1)) % p) == 1 | |
return p == 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is prone to false positives. e.g. 341