Problem 16

pow(2, 15) = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.
2的15次方等于32768,而这些数字(3+2+7+6+8)的和为26
What is the sum of the digits of the number pow(2, 1000)?
2的1000次方的位数之和为多少?
import math

power = math.pow(2, 1000)
sum_of_digits = 0
with open('power_of_two.txt', 'w') as f:
print('%d' % power, file=f)
with open('power_of_two.txt') as f:
for line in f:
for c in line:
try:
sum_of_digits += int(c)
except:
pass print(sum_of_digits)
												

最新文章

  1. 解决某些Android Permission denied
  2. [转]C#基础回顾:Asp.net 缓存
  3. BZOJ 1010 玩具装箱toy(四边形不等式优化DP)(HNOI 2008)
  4. Java中static的用法
  5. Winfrom 开发系统导航菜单
  6. JS对象与json字符串格式
  7. iOS开发获取缓存文件的大小并清除缓存
  8. 浅析CDN存在的必要性
  9. JavaScript—var lef const区别
  10. Python的布尔值与空值
  11. Python面向对象——多态
  12. 逆袭之旅.DAY08东软实训.多态~
  13. Spring Boot 中使用 Jedis 及 Lettuce的对比
  14. Terminal Service 终端链接
  15. tcp端口检测
  16. Android 布局之LinearLayout 子控件weight权重的作用详析
  17. redis知识树
  18. 51nod1464(trie + dfs)
  19. RunKit & NPM
  20. <转>C++位运算详解

热门文章

  1. ADS-B显示终端6.8
  2. samba笔记
  3. BZOJ 4525 二分
  4. pgsql 远程机器无法连接数据库报错处理方法
  5. Entity Framework Code First -- 延迟加载和预先加载
  6. backface-visibility当元素不面向屏幕时是否可见
  7. java如何设置文件的权限
  8. win2008系统日志不断出现【审核失败】
  9. 【技术累积】【点】【sql】【15】MySQL的TEXT和SELECT问题
  10. 如何将一个已有的项目托管到github或是码云上?git的配置