Project Eluer - 20
来源:互联网 发布:java包装简历 编辑:程序博客网 时间:2024/05/16 10:01
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!
翻译:
n!表示 n*(n-1)*....*3*2*1 的积。 10!= 3628800, 所有数位之和为 3+6+2+8+8+0+0 = 27 , 找出100的阶层的的所有数位之和?
思路:
看到这个题,就想到了python,只要有大数库,这个问题就很好解决了。代码如下:
product = 1for i in range(1,100+1):product *= iprint productresut = 0for i in str(product):resut += int(i)print resut
输出结果:
100! = 93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000
所有数位之和 = 648
0 0
- Project Eluer - 20
- Project Eluer - Problem 11
- Project Eluer - 14
- Project Eluer - 15
- Project Eluer - 16
- Project Eluer - 17
- Project Eluer - 18
- Project Eluer - 19
- Project Eluer - 21
- Project Eluer - 22
- Project Eluer - 23
- 有限差分法Eluer算法(求解常微分方程)
- Project Euler - Problem 20
- Project Euler 20
- Project Euler 16~20
- project euler 20
- project
- project
- QAuth2认证 -- ( 不使用友盟等 )自己实现第三方登录(UIWebView)、微博分享、等其他操作
- Removing Columns - CodeForces 496 C 水题
- 早来的圣诞礼物!--android 逆向菜鸟速参手册完蛋版
- 客户端升级架构
- 【C语言】递归实现元素的全排列和子集
- Project Eluer - 20
- 04数据挖掘原理-数据分析 数据描述
- 第三十篇:Windbg的基础知识
- Wifi 资源整理
- 获取textarea中的换行和空格并转义显示在网页上
- linux之alias命令
- 解决问题之道--使用Java实现数据的分组求和
- 线程7种状态的相互转换
- Tennis Game - CodeForces 497 B