# Powerful digit sum (Euler Problem 56)¶

Back to overview.

A googol ($10^{100}$) is a massive number: one followed by one-hundred zeros; $100^{100}$ 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, $a^b$, where $a, b < 100$, what is the maximum digital sum?

In [1]:

    def get_digit_sum(n):
        s = 0
        while n != 0:
            s += (n % 10)
            n //= 10
        return s

    assert(get_digit_sum(1337) == 14)
    assert(get_digit_sum(100**100) == 1)

In [2]:

    s = max([get_digit_sum(a**b) for a in range(1, 100) for b in range(1, 100)])
    print(s)
    assert(s == 972)

    972

In [ ]: