Problem 20

Problem 20

问题网址:https://projecteuler.net/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!
找出100!的结果,并将这个结果中的所有数字相加,得到的数字是多少?
tot = 1
for i in range(1, 101):
    tot *= i
print(tot)
sum = 0
for i in str(tot):
    sum += int(i)
print(sum)

 

posted @ 2019-06-02 16:29  no樂on  阅读(156)  评论(0编辑  收藏  举报