Implement a function fact_digits(n)
, that takes an integer and returns the sum of the factorials of each digit of n
.
For example, if n = 145
, we want 1! + 4! + 5!
.
Here's the signature:
def fact_digits(n):
pass
Examples:
fact_digits(101) == 3
fact_digits(111) == 3
fact_digits(145) == 145
fact_digits(999) == 1088640
Hints:
We've already solved a similiar problem. Think how you can use that to your advantage.