Skip to content

Instantly share code, notes, and snippets.

@jakedobkin
Created December 24, 2011 22:47
Show Gist options
  • Select an option

  • Save jakedobkin/1518494 to your computer and use it in GitHub Desktop.

Select an option

Save jakedobkin/1518494 to your computer and use it in GitHub Desktop.
Problem 74
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