Created
September 21, 2011 14:08
-
-
Save GrAndSE/1232121 to your computer and use it in GitHub Desktop.
Prime numbers searching using 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 primes(num): | |
| def is_prime(n): | |
| limit = int(n**0.5) + 1 | |
| for i in range(2, limit): | |
| if n % i == 0: | |
| return False | |
| return True | |
| return [n for n in range(2, num) if is_prime(n)] | |
| print primes(1000000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment