Computer Science, asked by pratishmoses, 7 months ago

Write a program which will input a number and check whether it is a special number or not. A number is said to be special if the sum of the factorials of the digits is equal to the original number Example: 145= 1! + 4 ! + 5 ! =1+24+120=145

Answers

Answered by pavithranatarajan855
2

Answer:

def fact(digit):

 if(digit==0):

   return 1

 else:

   return digit*fact(digit-1)

n=int(input())

sum=0

temp=n

while(n!=0):

 digit=n%10

 f=fact(digit)

 sum=sum+f

 n=n//10

if(sum==temp):

 print("Special number")

else:

 print("Not a special number")

Explanation:

Similar questions