Project Euler 20: (Iron)Python
- by Ben Griswold
In my attempt to learn (Iron)Python out in the open, here’s my solution for Project Euler Problem 20.
As always, any feedback is welcome.
# Euler 20
# http://projecteuler.net/index.php?section=problems&id=20
# n! means n x (n - 1) x ... x 3 x 2 x 1
# Find the sum of digits in 100!
import time
start = time.time()
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n-1)
print sum([int(i) for i in str(factorial(100))])
print "Elapsed Time:", (time.time() - start) * 1000, "millisecs"
a=raw_input('Press return to continue')