def Primedivisors(N): """return the list of Primedivisors for natural number N""" import Primelist import math import itertools import P3 primediv=[] div_num=1 divs=[1,N] if P3.IsPrime(N)==True: #return ([],2,divs) return [] a=Primelist.primes(N/2) #return primedivisors while(N!=1): for i in a: while N%i==0: N=N/i primediv.append(i) #return divisors number #for i in set(primediv): #div_num=div_num*(primediv.count(i)+1) ##return divisors #for i in range(1,len(primediv)+1,1): #b=itertools.combinations(primediv,i) #for j in b: #prod=1 #for k in j: #prod=prod*k # divs.append(prod) #return (primediv,div_num,set(divs)) return primediv
def CG_conjecture(N): """docstring for CG_conjecture""" a=Primelist.primes(N) for i in a[1:]: if IsSquareNum((N-i)/2): #print N,'=',i,'+','2*',math.sqrt((N-i)/2),'**2' return True return False
import Primelist from P3 import IsPrime listb = Primelist.primes(1000) lista = range(-999, 1000, 2) def f1(a, b): return lambda n: n ** 2 + a * n + b def Nprime(c): n = 0 nprime = 0 while c(n) > 0: if IsPrime(c(n)): n += 1 nprime += 1 else: break return nprime res = [] for a in lista: for b in listb: c = f1(a, b) n = Nprime(c) # print n,a,b res.append((n, a, b)) print max(res)
import Primelist import P3 def TruncatablePrime(N): """docstring for TruncatablePrime""" N=str(N) tmplist=[] for i in range(1,len(N)): tmplist.append(N[i:]) tmplist.append(N[0:len(N)-i]) #print tmplist tmplist=map(int,tmplist) for TruncatedNum in tmplist: if not(P3.IsPrime(TruncatedNum)): return False return True if __name__ == '__main__': inilist=Primelist.primes(1000000) result=[] for i in inilist: if TruncatablePrime(i): print i result.append(i) print sum(result[4:]),len(result)-4
results.append(N) return results def cyclic(N): """docstring for cyclic""" results=[] if len(str(N))==1: return [N] for i in str(N): if int(i) not in [1,3,7,9]: return [] return map(int,RingRotate(N)) def cyclicPrime(N): if cyclic(N)==[]: return [] for i in cyclic(N): if not(P3.IsPrime(i)): return [] return N if __name__ == '__main__': prims=Primelist.primes(1000000) result=[] for i in prims: if cyclicPrime(i): result.append(i) print result,len(result)
import math import itertools import Primelist if __name__ == '__main__': num=[] a=Primelist.primes(9999) a=[i for i in a if i>1000] for i in a: b=itertools.permutations(str(i)) for c in b: d=[map(int,x) for x in c] if d[0]!=0: k=d[0][0]*1000+d[1][0]*100+d[2][0]*10+d[3][0] if k in a: num.append(k) a.pop(a.index(k)) #print count,k if len(set(num))>=3: tmp=itertools.combinations(num,2) for comb in tmp: #print comb,sum(comb),num if sum(comb)/2 in num: print num,comb,sum(comb)/2 num=[]