summaryrefslogtreecommitdiff
path: root/Problem49.py
blob: f4576be78f4665b0bd59a04805514c7e3e98e26d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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))