diff options
author | Joshua Drake <joshua.drake@ditchwitch.com> | 2023-04-07 08:13:49 -0500 |
---|---|---|
committer | Joshua Drake <joshua.drake@ditchwitch.com> | 2023-04-07 08:13:49 -0500 |
commit | 1161f9a034de06a63538e3a9a0b7717098c744d9 (patch) | |
tree | 55bb842b2daa4f096eb7916a8d3630426fc1c376 /Problem41.py |
Diffstat (limited to 'Problem41.py')
-rw-r--r-- | Problem41.py | 30 |
1 files changed, 30 insertions, 0 deletions
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 |