Problem 20: Factorial Digit Sum
n! means n x (n - 1) x … x 3 x 2 x 1
For example, 10! = 10 x 9 x … x 3 x 2 x 1 = 3628800, and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27.
Find the sum of the digits in the number 100!
from math import factorial
def digital_sum(n):
"""Return the sum of the digits in integer n."""
return sum([int(i) for i in str(int(n))])
print(digital_sum(factorial(100)))
Click to reveal output
648