Create isprime.py
This commit is contained in:
parent
496fafa172
commit
e7fa428112
14
functions/isprime.py
Normal file
14
functions/isprime.py
Normal file
@ -0,0 +1,14 @@
|
||||
def isprime(event,context):
|
||||
n= event['data']
|
||||
if n == 2 or n == 3: return "Prime"
|
||||
if n < 2 or n%2 == 0: return "Not Prime"
|
||||
if n < 9: return "Prime"
|
||||
if n%3 == 0: return "Not Prime"
|
||||
r = int(n**0.5)
|
||||
f = 5
|
||||
while f <= r:
|
||||
print '\t',f
|
||||
if n%f == 0: return "Not Prime"
|
||||
if n%(f+2) == 0: return "Not Prime"
|
||||
f +=6
|
||||
return "Prime"
|
Loading…
Reference in New Issue
Block a user