-
-
Save hitecherik-gist/4219969 to your computer and use it in GitHub Desktop.
PY: Prime Number Checker
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
| import time | |
| def is_prime(n): | |
| if n is 0 or n is 1: | |
| return False | |
| else: | |
| for x in range(2, n): | |
| if n % x == 0: | |
| return False | |
| return True | |
| def is_pri(n): | |
| if n is 0 or n is 1: | |
| return False | |
| else: | |
| for x in range(2, 11): | |
| if n % x == 0: | |
| return False | |
| return True | |
| start = time.time() | |
| print is_prime(611953) | |
| end = time.time() | |
| print end - start | |
| start = time.time() | |
| print is_pri(611953) | |
| end = time.time() | |
| print end - start | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment