How to check if a number is curious number (sum of the factorials of each digit equal to itself) in Python

1 Answer

0 votes
import math

def sumFactorialDigits(num) :
    sum = 0
    while (num != 0) :
        sum += math.factorial(int(num % 10))
        num = int(num / 10)
    
    return sum
    
number = 145

if (number == sumFactorialDigits(number)) :
    print("Curious number")
else :
    print("Not curious number")




'''
run:

Curious number

'''

 



answered Jan 3, 2024 by avibootz
...