Strong Number in C

Strong Number in C



Input number: 145




Required knowledge

Basic C programmingIf elseFor loopWhile loopNested loop

What is Strong number?

Strong number is a special number whose sum of factorial of digits is equal to the original number.
For example: 145 is strong number. Since, 1! + 4! + 5! = 145

Logic to check Strong number

Step by step descriptive logic to check strong number.

  1. Input a number from user to check for strong number. Store this in a variable say num. Copy it to a temporary variable for calculations purposes, say originalNum = num.
  2. Initialize another variable to store sum of factorial of digits, say sum = 0.
  3. Find last digit of the given number num. Store the result in a variable say lastDigit = num % 10.
  4. Find factorial of lastDigit. Store factorial in a variable say fact.
  5. Add factorial to sum i.e. sum = sum + fact.
  6. Remove last digit from num as it is not needed further.
  7. Repeat steps 3 to 6 till num > 0.
  8. After loop check condition for strong number. If sum == originalNum, then the given number is Strong number otherwise not.

Learn more - Program to find sum of digits of number.