Last active
July 5, 2017 14:29
-
-
Save pebble8888/47ae3575c4ef3a5257a841bfceaa981c to your computer and use it in GitHub Desktop.
is_prime python
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 isprime(n): | |
| if n == 2: | |
| return True | |
| if n == 3: | |
| return True | |
| if n % 2 == 0: | |
| return False | |
| if n % 3 == 0: | |
| return False | |
| i = 5 | |
| w = 2 | |
| while i * i <= n: | |
| if n % i == 0: | |
| return False | |
| i += w | |
| w = 6 - w | |
| return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment