コード例 #1
0
ファイル: p47.py プロジェクト: pconerly/projecteuler
def p47():
    i = 0
    while True:
        i += 1
        temp = pelib.remove_dupes(pelib.prime_factors(i))
        if len(temp) == 4:
            count += 1
            if count == 4:
                return (i - 3)
        else:
            count = 0
コード例 #2
0
def p23():
    #find perfect divisors up to 28123
    #find divisors of each number
    perfectdivisors = []
    for i in range(28124):
        if sum(divisors(i)) > i:
            perfectdivisors.append(i)
    #for i in range(28124):
    #return len(perfectdivisors)
    sumabundants = []
    for i in range(0, len(perfectdivisors)):
        j = 0
        while (perfectdivisors[i] + perfectdivisors[j]) < 28124:
            sumabundants.append(perfectdivisors[i] + perfectdivisors[j])
            j = j + 1
    sumabundants.sort()
    sumabundants = pelib.remove_dupes(sumabundants)
    temp = 0
    for i in range(1, 28124):
        if i in sumabundants:
            pass
        else:
            temp += i
    return temp
コード例 #3
0
ファイル: p23.py プロジェクト: pconerly/projecteuler
def p23():
    #find perfect divisors up to 28123
    #find divisors of each number
    perfectdivisors = []
    for i in range(28124):
        if sum(divisors(i)) > i:
            perfectdivisors.append(i)
    #for i in range(28124):
    #return len(perfectdivisors)
    sumabundants = []
    for i in range(0,len(perfectdivisors)):
        j = 0
        while (perfectdivisors[i]+perfectdivisors[j]) < 28124:
            sumabundants.append(perfectdivisors[i]+perfectdivisors[j])
            j = j + 1
    sumabundants.sort()
    sumabundants = pelib.remove_dupes(sumabundants)
    temp = 0
    for i in range(1,28124):
        if i in sumabundants:
            pass
        else:
            temp += i
    return temp