Power digit sum : Problem 16 Euler Project
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 Code
def powerDigitSum():
l = 2**1000
strNumb = str(l)
sumFact = 0
for i in range(len(strNumb)):
sumFact = sumFact + int(strNumb[i])
print "sum of the digits in the number! is",sumFact
powerDigitSum()
What is the sum of the digits of the number 21000?
Python Code
def powerDigitSum():
l = 2**1000
strNumb = str(l)
sumFact = 0
for i in range(len(strNumb)):
sumFact = sumFact + int(strNumb[i])
print "sum of the digits in the number! is",sumFact
powerDigitSum()
No comments:
Post a Comment