Created
November 24, 2019 15:21
-
-
Save esron/d70384dd61c337b81ad5a362b52d0da5 to your computer and use it in GitHub Desktop.
Determ if a positive integer is prime
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 <= 3: | |
| return n > 1 | |
| if not n % 2 or not n % 3: | |
| return False | |
| i = 5 | |
| while(i * i <= n): | |
| if not n % i or not n % (i + 2): | |
| return False | |
| i += 6 | |
| return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment