Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- c=2
- primi=[2]
- def getcomp(num):
- out = []
- num = str(num)
- ln = len(num)
- for ran in range(1,ln):
- k = int(num[0:ran])
- if isprime(k):
- out.append(k)
- for ran in range(1,ln):
- k = int(num[ran:ln])
- if isprime(k):
- out.append(k)
- return list(set(out))
- def acceptable(seed,elenco):
- for k in elenco:
- if not (isprime(int(str(seed)+str(k))) and isprime(int(str(k)+str(seed)))):
- return False
- return True
- def isprime(num):
- if num<c:
- return (num in primi)
- for t in range(2,int(num**0.5)+1):
- if num%t==0:
- return False
- return True
- def nextprime(finoa):
- global c,primi
- while c<(finoa+1)*10:
- p=True
- for t in primi:
- if t>(c)**0.5+1:
- break
- if c%t==0:
- p = False
- break
- if p:
- primi.append(c)
- c=c+1
- def getprime(finoa):
- primi = [2]
- c=2
- while c<(finoa+1)*10:
- p=True
- for t in primi:
- if t>(c)**0.5+1:
- break
- if c%t==0:
- p = False
- break
- if p:
- primi.append(c)
- c=c+1
- return primi
- def nextprimeb():
- global c,primi
- z = len(primi)
- while z==len(primi):
- p=True
- for t in primi:
- if t>(c)**0.5+1:
- break
- if c%t==0:
- p = False
- break
- if p:
- primi.append(c)
- c=c+1
- #nextprime(3)
- #print getcomp(36733)
- def getother(clist):
- z=0
- while not acceptable(z,clist):
- if z>100000:
- return clist
- z = primi[-1]
- #print z
- nextprimeb()
- return getother(clist+[z])
- l = getprime(20)
- print 'fuori>',getother([3])
- for cur in [1,2]:
- print 'dentro>',getother([3])
- #print cur,
- #print len(getother([3]))
- # print getother([cur]),sum(getother([cur]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement