Project Euler Problem 16
2015-08-13 18:01
288 查看
原题:
215 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.
What is the sum of the digits of the number 21000?
由于2的1000次方是一个很大的数,远远超出范围,也因此一直没有好办法解这个题,最近看python,发现python对这个没有限制
(刚刚看的一点python内容,立马就用,不喜勿喷啊,不过发现python真的很强大,几行代码就搞定)
以下是python的代码:
215 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.
What is the sum of the digits of the number 21000?
由于2的1000次方是一个很大的数,远远超出范围,也因此一直没有好办法解这个题,最近看python,发现python对这个没有限制
(刚刚看的一点python内容,立马就用,不喜勿喷啊,不过发现python真的很强大,几行代码就搞定)
以下是python的代码:
# Project Euler 16 sum1 = 0 x = 2**1000 y = str(x) for i in y: sum1 = sum1+int(i) print sum1 #The result is 1366
相关文章推荐
- AutoUpgraderPro
- Android自定义View(四)——仿Android5.0波纹效果
- 肉鸡类问题排查思路
- JavaScript 正则小例子
- web开发在线文档
- Caffe学习笔记5-BLAS与boost::thread加速
- 贪吃蛇android源码分享
- 终于找到了不用自定义一个activity栈,来关闭所有activity的方法了!!!
- HDOJ--3371---Connect the Cities
- socket链接和http链接的区别
- html5学习笔记(13)
- AutoLayout初战----Masonry与FDTemplateLayoutCell实践
- 分类精度评价方法
- php常用库函数
- Fragment进阶(六)----->Fragment与Activity通讯3种方式
- iOS开发 - 加载三方字体库
- 【转】Java发送Http请求
- 如何编写NopCommerce插件(二)编写插件
- 前端学习-试卷
- 输入n个整数,输出其中最小的k个