Computer Science, asked by saksham838383838, 3 months ago

Program
Write a program to input a number and print whether the number is a special number or not.
A number is said to be a special number, if the sum of the factorial of the digits of the number is same as the original
For example, 145 is a special number because 1! + 4! + 5! = 1 + 24 + 120 = 145.
rimary, 40585 is special number because 4! + O! + 5! + 8! + 5! = 24 + 1 + 120 + 40320 + 120 = 40585. [ICSE-2011)
number)​

Answers

Answered by roymananjay
0

Answer:

#include <iostream>

using namespace std;

int main()

{

int n;

int sum=0;

cout<<"Enter a number to check the number is special number or not :- \n";

cin>>n;

int total=n;

while(n>0)

{

int m=n;

m=m%10;

int fact=1;

for(int i=m;i>=1;i--)

{

fact=fact*i;

}

sum=sum+fact;

n=n/10;

}

if(sum==total)

{

cout<<"\nNumber is special number ";

}

else

{

cout<<"\nNumber is not special number ";

}

return 0;

}

Attachments:
Similar questions