Factorial digit sum
Problem 20
n! means n × (n ? 1) × ... × 3 × 2 × 1
For example, 10! = 10 × 9 × ... × 3 × 2 × 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!
|
python code:
import math
sqrt=math.sqrt
result=1
for i in range(1,101):
result*=i
temp=str(result)
result=0
k=len(temp)
for i in range(0,k):
result+=int(temp[i])
print(result)
time: <1s
时间: 2024-10-06 16:01:43