Created
December 24, 2011 22:47
-
-
Save jakedobkin/1518494 to your computer and use it in GitHub Desktop.
Problem 74
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
| from math import factorial | |
| def fadd(n): | |
| sum = 0 | |
| for i in range (0,len(str(n))): | |
| sum += factorial(int(str(n)[i:i+1])) | |
| return sum | |
| def roundfadd(n,array,p): | |
| if n in sequences: | |
| p = p + sequences[n]-1 | |
| return p | |
| elif fadd(n) in array: | |
| return p | |
| else: | |
| p += 1 | |
| array.append(fadd(n)) | |
| return roundfadd(fadd(n),array,p) | |
| n = 1000000 | |
| count = 0 | |
| sequences = {} | |
| for x in range (0,n): | |
| a = roundfadd(x,[],1) | |
| sequences[x] = a | |
| if a==60: | |
| count+=1 | |
| print count |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment