-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheuler-p49.py
More file actions
43 lines (36 loc) · 950 Bytes
/
Copy patheuler-p49.py
File metadata and controls
43 lines (36 loc) · 950 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# -*- coding: utf-8 -*-
"""
Created on Thu Jul 10 15:22:33 2025
@author: phoeb
"""
## https://ramonsmathsblog.wordpress.com/2020/08/27/project-euler-problem-49-python-solution/
from sympy import *
primes=[]
for i in range(1000,10000):
if isprime(i):
primes.append(i)
from itertools import permutations
def permute(n):
return list(set([int(''.join(p)) for p in permutations(str(n))]))
def prime_permute(n):
perms = permute(n)
prime_perms =[]
for p in perms:
if p in primes:
prime_perms.append(p)
prime_perms.remove(n)
return sorted(prime_perms)
def sequence_gen(n):
seq_bool=False
global seq
seq=[]
fin =[]
perms = prime_permute(n)
for q in perms:
if (q+(q-n)) in perms:
seq =[n,q,2*q-n]
seq_bool=True
return seq_bool
for p in primes:
if sequence_gen(p):
print(seq)