Add function to check primality
This commit is contained in:
parent
a062b67759
commit
a0c3ebee6f
@ -1,4 +1,4 @@
|
||||
|
||||
import math
|
||||
from functools import wraps
|
||||
|
||||
|
||||
@ -14,3 +14,13 @@ def timeit(name):
|
||||
return result
|
||||
return wrapper
|
||||
return profile
|
||||
|
||||
|
||||
|
||||
def is_prime(n):
|
||||
if n % 2 == 0 and n > 2:
|
||||
return False
|
||||
for i in range(3, int(math.sqrt(n)) + 1, 2):
|
||||
if n % i == 0:
|
||||
return False
|
||||
return True
|
Loading…
x
Reference in New Issue
Block a user