summaryrefslogtreecommitdiff
path: root/Problem49.py
diff options
context:
space:
mode:
Diffstat (limited to 'Problem49.py')
-rw-r--r--Problem49.py21
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))