From 1161f9a034de06a63538e3a9a0b7717098c744d9 Mon Sep 17 00:00:00 2001 From: Joshua Drake Date: Fri, 7 Apr 2023 08:13:49 -0500 Subject: Initial Commit --- Problem41.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Problem41.py (limited to 'Problem41.py') diff --git a/Problem41.py b/Problem41.py new file mode 100644 index 0000000..72bcbac --- /dev/null +++ b/Problem41.py @@ -0,0 +1,30 @@ +import math +def isPandigital(n): + n = str(n) + for x in range(0,len(n)): + if n.count(n[x]) > 1 or n.count("0") != 0: + return False + else: continue + return True +def isPrime(n): + for x in range(2,int(math.sqrt(n))): + if n%x == 0: return False + return True +def nextPrime(n): + n-=1 + while isPrime(n) == False: + n-=1 + return n + +x = 7654320 +while(x > 2): + if isPandigital(x): + print("Answer is:",x) + break + x = nextPrime(x) + print(x) + + + + + \ No newline at end of file -- cgit v1.2.3