mirror of
https://github.com/correl/euler.git
synced 2024-11-30 19:19:54 +00:00
Problem 020
git-svn-id: file:///srv/svn/euler@47 e5f4c3ec-3c0c-11df-b522-21efaa4426b5
This commit is contained in:
parent
cd6bea96ee
commit
8978f31f65
1 changed files with 15 additions and 0 deletions
15
e020.py
Normal file
15
e020.py
Normal file
|
@ -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
|
Loading…
Reference in a new issue