Function call in C Language 02-a positive integer with three digits = the sum of the factorial values of each digit
// Function call + Enumeration
/*
========================================================== ============================
Question: Calculate the positive integer of a three-digit number = the sum of the factorial of all its numbers!
For example: 145 = 1! + 4! + 5 !.
========================================================== ============================
*/
# Include
Int J (int n)
{
Int t = 1, I;
For (I = 1; I <= n; I ++)
T * = I;
Return (t );
}
Main ()
{
Int s, I, ge, shi, bai, qian;
For (s = 100; s <1000; s ++)
{
Ge = s % 10;
Shi = s/10% 10;
Bai = s/100% 10;
If (s = J (ge) + J (shi) + J (bai ))
Printf (% d = % d! + % D! + % D! , S, bai, shi, ge );
}
}
/*
========================================================== ============================
Comments: First, write a Function J for factorial, and then use division and remainder to find "Ten hundred"
The number in bits, and the number that meets the if condition is found through the enumeration method.
========================================================== ============================
*/