コード例 #1
0
ファイル: problem34.py プロジェクト: greb/projecteuler
def is_curious(n):
    sum = 0
    for c in str(n):
        sum = sum + factorial(int(c))
    if sum == n:
        return True
    else:
        return False
コード例 #2
0
ファイル: problem43.py プロジェクト: greb/projecteuler
def problem42():
    result = []
    pandigit = "0123456789"
    for x in xrange(factorial(10)-1):
        number = permutation(pandigit,x)
        if divisiontest(number):
            result.append(int(number))
    return sum(result)
コード例 #3
0
ファイル: problem24.py プロジェクト: greb/projecteuler
def permutator(digits, permutation):
    result = ""
    digits = [c for c in digits]
    while len(digits) > 0:
        selection = factorial(len(digits)-1)
        index = permutation / selection
        permutation = permutation % selection
        result = result + digits[index]
        del digits[index]
    return result
コード例 #4
0
ファイル: problem49.py プロジェクト: greb/projecteuler
def problem49():
    result = []
    primes = [x for x in prime_generator(10000)]
    d = 3330
    for n in xrange(1000, 10000):
        if n not in primes:
            continue
        n_str = str(n)
        per = [int(permutation(n_str, x)) for x in xrange(factorial(4))]
        pri = [x for x in per if x in primes]
        if n+d in pri and n+2*d in pri:
            result.append(str(n) + str(n+d) + str(n+d+d))
    return list(set(result))
コード例 #5
0
ファイル: problem34.py プロジェクト: greb/projecteuler
def problem34():
    result = []
    for x in xrange(3, factorial(9)):
        if is_curious(x):
            result.append(x)
    return sum(result)
コード例 #6
0
ファイル: problem41.py プロジェクト: greb/projecteuler
def problem41():
    pandigit = "987654321"
    for i in xrange(9):
        for x in xrange(factorial(9-i)-1):
            if is_prime(int(permutation(pandigit[i:], x))):
                return permutation(pandigit[i:], x)