Skip to content

Instantly share code, notes, and snippets.

@toannd96
Created April 14, 2018 09:43
Show Gist options
  • Save toannd96/bc6a5de7a7e7566a3ffaed711344d34b to your computer and use it in GitHub Desktop.
Save toannd96/bc6a5de7a7e7566a3ffaed711344d34b to your computer and use it in GitHub Desktop.
BT
def sum_digits(number):
str_number = str(number)
sum = 0
for i in range(0, len(str_number)):
sum += int(str_number[i])
return sum
sum_digits(2**1000)
>>>1366
sum(int(num) for num in str(2**1000)) >>> 1366
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment