Friday, March 29, 2013

project euler problem 074

Digit factorial chains

This problem is interesting. It is not difficult to brute force. But finding a very efficient algorithm is not that easy.  My code runs 0.7second without too much memory cost. The key is to avoid duplicate computation.

PE problem makers like factorial quite a bit. There are quite a few more difficult problems that are related with factorials.

update 09/25/2017:
the old code is still hard to read. I rewrote the recursive function to find the different numbers in the list. The logic is easier to understand now.

No comments:

Post a Comment