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')

2 Comments to “Project Euler 20: (Iron)Python”

  1. John says:

    Isn’t the sum of the digits in 100 = 1 + 0 + 0 = 1?????

  2. BlueRaja says:

    Pretty much word-for-word exactly the same as my solution.

    Wait until you get to the second page of problems, that’s when they *really* start getting difficult :)