From 8978f31f659676f66d2ed4dceae2d892e5fb628e Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Wed, 14 Apr 2010 19:34:18 +0000 Subject: [PATCH] Problem 020 git-svn-id: file:///srv/svn/euler@47 e5f4c3ec-3c0c-11df-b522-21efaa4426b5 --- e020.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 e020.py diff --git a/e020.py b/e020.py new file mode 100644 index 0000000..a879cec --- /dev/null +++ b/e020.py @@ -0,0 +1,15 @@ +# Could use math.factorial, but that takes the fun out of it, doesn it +def factorial(n): + f = n + i = n - 1 + while i > 1: + f = f * i + i = i - 1 + return f + +f = str(factorial(100)) +sum = 0 +for c in f: + sum = sum + int(c) + +print 'Sum of digits in 100!:', sum \ No newline at end of file