示例#1
0
文件: euler51.py 项目: verted/euler
import primeGenerator

primeTest = primeGenerator.gen(150000000)
numOnDiag = 1
numPrimes = 0
dim = 0
num = 1
while numPrimes / numOnDiag > 0.10 or numPrimes == 0:
    dim += 2
    for i in range(4):
        num += dim
        numPrimes += primeTest[num]
    numOnDiag += 4
    print(numPrimes, numOnDiag, numPrimes / numOnDiag, dim)
print(dim)
示例#2
0
import primeGenerator
bList = primeGenerator.gen(1000)
bList = [x for x in range(len(bList)) if bList[x] == 1]
primeTest = primeGenerator.gen(2000000)
nMax = 0
aMax = 0
bMax = 0
for a in range(-999,1000):
    for b in bList:
        n = 0
        while primeTest[n**2 + a*n +b]:
            n+=1
        if n >nMax:
            aMax = a
            bMax = b
            nMax = n
print(aMax,bMax,aMax*bMax,nMax)
示例#3
0
文件: euler51.py 项目: verted/euler
import primeGenerator

primeTest = primeGenerator.gen(150000000)
numOnDiag = 1
numPrimes = 0
dim = 0
num = 1 
while numPrimes/numOnDiag > 0.10 or numPrimes == 0:
    dim += 2
    for i in range(4):
        num+= dim
        numPrimes += primeTest[num]
    numOnDiag += 4
    print(numPrimes, numOnDiag, numPrimes/numOnDiag, dim)
print(dim)