Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- primes = [2]
- for value in xrange(3, 10000000, 2):
- divisible = False
- for prime in primes:
- # Possible improvement: calculate floor(sqrt(value)) once outside this loop and check if prime <= floor(sqrt(value)) or something, sqrt is a much heavier function than **2 but would only have to be done once per value
- if prime**2 > value:
- break
- if value%prime == 0:
- divisible = True
- break
- if not divisible:
- primes.append(value)
- print value
Advertisement
Add Comment
Please, Sign In to add comment