Project Euler 74 - Digit Factorial Chain

Official link:

Thought Process

I did the is problem after Problem 95 and I used a similar code

  1. Created an array = [0]*(10^6 + 1)

  2. Loop through x from 1 to 10^6 and let array[x] = factorial_digit_sum(x) (This is just a modified sum_digit code)

    • We now have an array where we can very quickly create chains for example array[169] = 36301 and then array[36301] = 1454

  3. Go through the array and keep track of the length of the chain created, and for this problem I added a try-except incase array[x] > 10^6 then we manually calculate factorial_digit_sum(array[x])

Code takes ~10 seconds

Interactive Code

Please input an integer (yourinput)

Code will output the number of chains length 60 < yourinput