import math number = 2458333 sum_of_factorials = sum(math.factorial(int(digit)) for digit in str(number)) print(sum_of_factorials, number == sum_of_factorials)