原题:
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