示例#1
0
def is_curious(n):
    return sum([factorial(x) for x in get_digits(n)]) == n
示例#2
0
def is_npower_number(i, n=4):
    """Return True if sum of `n`th power of digits in `i` equates `i`"""
    assert i > 1
    return i == sum(a**n for a in get_digits(i))
示例#3
0
def truncatable_from_left(n):
    d = get_digits(n, integer=False)
    m = [is_prime(int("".join(d[i:]))) for i in range(len(d))]
    return reduce(lambda x, y: x and y, m)
示例#4
0
def truncatable_form_right(n):
    d = get_digits(n, integer=False)
    m = [is_prime(int("".join(d[:i]))) for i in range(1, len(d))] + [is_prime(n)]
    return reduce(lambda x, y: x and y, m)
示例#5
0
#!/usr/bin/python
# coding: UTF-8
"""
@author: CaiKnife

Powerful digit sum
Problem 56
A googol (10100) is a massive number: one followed by one-hundred zeros; 100100 is almost unimaginably large: one followed by two-hundred zeros. Despite their size, the sum of the digits in each number is only 1.

Considering natural numbers of the form, ab, where a, b  100, what is the maximum digital sum?
"""

from euler import get_digits

m = 0
for a in xrange(1, 100):
    for b in xrange(1, 100):
        digit_sum = sum(get_digits(a ** b))
        if m < digit_sum:
            m = digit_sum

print m