Problem 16
Posted noonjuan
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Problem 16相关的知识,希望对你有一定的参考价值。
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)
以上是关于Problem 16的主要内容,如果未能解决你的问题,请参考以下文章
《DSP using MATLAB》Problem 2.16
ubuntu16.04 yum报错:There are no enabled repos. Run “yum repolist all“ to see the repos you have.(代码片段