Skip to content

Instantly share code, notes, and snippets.

@starfys
Last active April 13, 2018 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save starfys/6cb16680876c4ccffc26ab18b9264a0e to your computer and use it in GitHub Desktop.
Save starfys/6cb16680876c4ccffc26ab18b9264a0e to your computer and use it in GitHub Desktop.
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