# Strong Number Or Not

## Strong Number or Not:-

A strong number is a special number whose sum of the factorial of the digits is equal to the original number. For instance, the number 145 is a strong number because 1! + 4! + 5! = 145.

The following algorithm and program will help to determine if a given number is a factorial.

## Algorithm to test whether a number is Strong or not:

Step 1. Start

Step 2. Ask a number from the user to test if it is a strong number.

Step 3. Store this number in a variable, say num and copy its value to a temporary variable for further calculations (originalNum =num).

Step 4. Initialize a variable to store the sum of the factorial of the digits, say sum = 0.

Step 5. Calculate the last digit of the given number and store the result in a variable. Let this variable be lastDigit = num %10.

Step 6. Calculate the factorial of the last digit and store its value in a variable, say fact.

Step 7. Add the values, in fact, to sum or, sum = sum + fact.

Step 8. Remove the last digit from num as it is not required in the later stages.

Step 9. Repeat steps 3 to 6 until the value of num is greater than zero.

Step 10. At the end of the loop, check the condition for the strong number. If sum == originalNum, then the number inserted by the user is a Strong Number, otherwise, it is not.

### C Program to check wheatear a number is Strong

```/**C program to check Strong Number */
#include <stdio.h>
int main()
{
int i, original_N, number, l_Digit, sum;
long factorial;
/* Ask a number from the user */
printf("Insert a number: ");
scanf("%d", &number);
/* Copy the value of number to a temporary variable */
Original_N = number;
sum = 0;
/* Calculate the sum of factorial of digits */
while(number > 0)
{
/* Calculate the last digit of number */
l_Digit = number % 10;
/* Calculate the factorial of last digit */
factorial = 1;
for(i=1; i<=l_Digit; i++)
{
factorial = factorial * i;
}
/* Add value of factorial to sum */
sum = sum + factorial;
number = number / 10;
}
/* Condition to check Strong Number */
if(sum == original_N)
{
printf("%d is STRONG NUMBER", original_N);
}
else
{
printf("%d is NOT STRONG NUMBER", original_N);
}
return 0;
}```

### Output

```Insert a number: 154
145 is a STRONG NUMBER.```