65 lines
1.0 KiB
Python
65 lines
1.0 KiB
Python
'''
|
|
from string import maketrans, translate
|
|
|
|
def numbreak(x):
|
|
out = []
|
|
while x != 0:
|
|
out.append(x % 10)
|
|
x /= 10
|
|
return set(out)
|
|
|
|
def numloop(x, a, lis):
|
|
out = []
|
|
for i in range(10 - a):
|
|
tt = maketrans(str(a), str(i + a))
|
|
tmp = int(translate(str(x), tt))
|
|
if isp(tmp, lis):
|
|
out.append(tmp)
|
|
return out
|
|
|
|
def isp(x, lis):
|
|
for i in lis:
|
|
if x % i == 0:
|
|
return False
|
|
if x < i ** 2:
|
|
break
|
|
return True
|
|
|
|
def makeP(x):
|
|
p = [2]
|
|
P = [2]
|
|
n = 3
|
|
while n < x:
|
|
for i in p:
|
|
if n % i == 0:
|
|
break
|
|
else:
|
|
P.append(n)
|
|
n += 2
|
|
while n > p[-1] ** 2:
|
|
p.append(P[len(p)])
|
|
return P
|
|
|
|
prime = makeP(100000)
|
|
|
|
def main():
|
|
xx = 56003
|
|
while 1:
|
|
ss = numbreak(xx)
|
|
for syn in range(3):
|
|
if syn in ss:
|
|
tmp = numloop(xx, syn, prime)
|
|
if len(tmp) >= 8:
|
|
print(xx, tmp)
|
|
return
|
|
xx += 2
|
|
while not isp(xx, prime): xx += 2
|
|
|
|
main()
|
|
'''
|
|
|
|
from tools import number_theory
|
|
|
|
prime = list(number_theory.make_prime(1000))
|
|
print(prime)
|