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 /Problem49.py |
Diffstat (limited to 'Problem49.py')
-rw-r--r-- | Problem49.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Problem49.py b/Problem49.py new file mode 100644 index 0000000..f4576be --- /dev/null +++ b/Problem49.py @@ -0,0 +1,21 @@ +def isPrime(n): + for x in range(2,int(n/2)+1): + if n%x == 0: return False + return True +def permprimes(n): + strn = str(n) + perms = [] + primes = [] + perms.append(int(strn[0]+strn[1]+strn[2]+strn[3])) + perms.append(int(strn[0]+strn[2]+strn[1]+strn[3])) + perms.append(int(strn[1]+strn[0]+strn[2]+strn[3])) + perms.append(int(strn[1]+strn[2]+strn[0]+strn[3])) + perms.append(int(strn[2]+strn[1]+strn[0]+strn[3])) + perms.append(int(strn[2]+strn[0]+strn[1]+strn[3])) + for x in range(0,len(perms)): + if isPrime(perms[x]): primes.append(perms[x]) + return primes +for x in range(1000,10000): + if len(permprimes(x)) < 3: continue + if (permprimes(x).count(x+3330) > 0) and (permprimes(x).count(x+6660) > 0): + print(str(x)+str(x+3330)+str(x+6660)) |