示例#1
0
文件: problem47.py 项目: Helgeb/euler
def solve(n, max):
    primeList = []
    primeList = primes.primesUpTo(max)
    i = 1
    while not hasProp(i, primeList, n):
        i += 1
    return i
示例#2
0
文件: problem49.py 项目: Helgeb/euler
def solve():
    primeList, perms = [], []
    primeList = primes.primesUpTo(10000)
    for p in filter(lambda n: n > 999, primeList):
        perms = []
        for q in allPerms(str(p)):
            if int(q) > 999 and int(q) in primeList and not int(q) in perms:
                perms.append(int(q))
        if len(perms) >= 3:
            if hasProp(perms):
                print(perms)
示例#3
0
文件: problem51.py 项目: Helgeb/euler
def solve(max, n):
    tStart = time.time()
    primeList = []
    primeList = primes.primesUpTo(max)
    primeSet = set(primeList)
    print("Anzahl Primzahlen: ", len(primeList))
    for p in primeSet:
        for i in powerset(list(range(0, len(str(p))))):
            if myMatch(p, i, n, primeSet):
                print("Run Time = " + str(time.time() - tStart))
                print(p)
    print("Run Time = " + str(time.time() - tStart))
示例#4
0
文件: problem69.py 项目: Helgeb/euler
def solve():
    tStart = time.time()
    pr = primes.primesUpTo(1000)
    r = 1
    for p in pr:
        r *= p
        if r>1000000:
            r = r / p
            break
    return r
    
    print("Run Time = " + str(time.time() - tStart))
示例#5
0
文件: problem35.py 项目: Helgeb/euler
def solve(max): 
    tStart = time.time()
    list = [2, 5]
    primeList = primes.primesUpTo(max)
    fastPrimeCheck =  primes.primesArrayUpTo(max)
    for p in primeList:
        if not '2' in str(p) and not '5' in str(p):
            noPrime = False
            for q in allcyc_perms(str(p)):
                noPrime = noPrime or not fastPrimeCheck[int(q)]
            if not noPrime:
                list.append(p)
        
    print("Run Time = " + str(time.time() - tStart))
    print('Ergebnis: ', list)
    print('Ergebnis: ', len(list))    
示例#6
0
文件: problem50.py 项目: Helgeb/euler
def solve(max, n, m):
    tStart = time.time()
    primeList = []
    primeList = primes.primesUpTo(max)
    isPrime = primes.primesArrayUpTo(max)
    print("Anzahl Primzahlen: ", len(primeList))
    longestList = []
    for i in range(n, m):
        temp = primeList[i:]
        s = sum(temp)
        while len(temp) > len(longestList):
            if s < 1000000 and isPrime[s]:
                longestList = temp
            s -= temp[-1:][0]
            temp = temp[:-1]
    print(len(longestList))
    print(sum(longestList))
    print("Run Time = " + str(time.time() - tStart))