From e7fa428112e8dce63e49824552d6daf5002e9ccf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torma=20Krist=C3=B3f?= Date: Fri, 26 Apr 2019 15:36:50 +0200 Subject: [PATCH] Create isprime.py --- functions/isprime.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 functions/isprime.py diff --git a/functions/isprime.py b/functions/isprime.py new file mode 100644 index 0000000..c30909f --- /dev/null +++ b/functions/isprime.py @@ -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"