Let’s assume that an integer has digits and that is the sum of the factorials of those digits. How big can be? We quickly find that since the largest sum of factorials we can produce from an 8-digit number is itself a 7-digit number (set all digits equal to 9 and look at , which only has 7 digits). So, we know the numbers that we're looking at are at most 7-digit numbers. Since would give , we have the following implementation in Sage