示例#1
0
def sum_factorial_digits(n):
    """Sums the digits in n!"""

    # First get a BigInt
    big = BigInt([n])

    # Now factorial it
    for i in range(1, n):
        big = big * (n - i)

    return sum_digits(big)
示例#2
0
from util.bigint import BigInt, sum_digits


def exponentiate(x, n):
    """Raises x to the power of n. Returns a BigInt"""
    result = BigInt([x])
    for i in range(2, n + 1):
        result = result * x
    return result


print sum_digits(exponentiate(2, 1000))