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?
用python绕开那些复杂的大数计算和溢出的考虑!
#!/usr/bin/env python
# coding: utf-8
def SumOfDigits(n):
sum = 0
while n/10:
sum += n%10
n /= 10
sum += n
return sum
def Ans():
import math
n = math.pow(2, 1000)
return SumOfDigits(int(n))
if __name__ == "__main__":
print Ans()