Skip to content

Instantly share code, notes, and snippets.

@Shibly
Created May 14, 2013 09:59
Show Gist options
  • Save Shibly/5574918 to your computer and use it in GitHub Desktop.
Save Shibly/5574918 to your computer and use it in GitHub Desktop.
Sum of digits
def sum_digits(n):
result = 0
while n != 0:
result = result + (n % 10)
n = n / 10
return result
print sum_digits(2**50)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment