feat(solution): problem #49

main
steven 2023-08-02 12:54:28 -04:00
parent f4e606a6d7
commit 8722d0a963
1 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1,30 @@
from itertools import permutations
import math
def is_prime(n):
for i in range(2, math.floor(math.sqrt(n) + 1)):
if n % i == 0:
return False
return True
def list_to_int(list):
n = 0
for i in list:
n = (n * 10) + int(i)
return n
for i in range(1000,10000):
if is_prime(i):
iPermutations = list(permutations(list(str(i))))
primePermutations = []
primePermutations.append(i)
primeCounter = 1 # starting number is already a prime
for i in iPermutations:
currentPermutation = list_to_int(i)
if currentPermutation == primePermutations[-1] + 3330 and int(i[0]) != 0 and is_prime(currentPermutation):
if not currentPermutation in primePermutations:
primePermutations.append(currentPermutation)
primeCounter += 1
if primeCounter == 3:
print(primePermutations)