Created
November 24, 2011 20:02
-
-
Save jakedobkin/1392176 to your computer and use it in GitHub Desktop.
Euler 20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # set initial variable to hold the number we want to factorial | |
| initial = 100 | |
| print initial,"! is equal to" | |
| # do the factorial | |
| i = initial | |
| while (i > 0): | |
| initial = initial * i | |
| i = i - 1 | |
| # convert factorial to string, cut and add up the digits, print answer | |
| sum=0 | |
| initial = str(initial) | |
| while (i < len(initial)): | |
| x = initial[i:i+1] | |
| x = int(x) | |
| sum = sum + x | |
| i = i +1 | |
| print sum |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment