Last active
April 13, 2018 15:49
-
-
Save starfys/6cb16680876c4ccffc26ab18b9264a0e to your computer and use it in GitHub Desktop.
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
from math import sqrt | |
import time | |
def is_prime(n): | |
if n == 1 or (n > 2 and n % 2 == 0): | |
return False | |
else: | |
rbool = True | |
sroot = int(sqrt(n) + 1) | |
for i in range(3,sroot,2): | |
if n % i == 0: | |
rbool = False | |
break | |
return rbool | |
start = time.time() | |
for _ in range(100): | |
list(map(is_prime, range(1000000))) | |
duration = time.time() - start | |
print(duration) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment