首页 > 其他 > 详细

Problem 20

时间:2019-06-02 16:56:22      阅读:94      评论:0      收藏:0      [点我收藏+]

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)

 

Problem 20

原文:https://www.cnblogs.com/noonjuan/p/10963310.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!