Skip to content

Instantly share code, notes, and snippets.

@hitsumabushi
Created August 10, 2012 22:25
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save hitsumabushi/3318617 to your computer and use it in GitHub Desktop.
Dayly programing (Project Euler:#20)
#!/usr/bin/python
from math import factorial
def digit_sum(num,sum=0):
if num > 0:
num,sum = int(num / 10), sum + (num % 10)
return digit_sum(num,sum)
else:
return sum
print(digit_sum(factorial(100)))
#=>648
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment