Strong Numbers are the numbers whose sum of factorial of digits is equal to the original number. Given a number, check if it is a Strong Number or not.
Input : n = 145 Output : Yes Sum of digit factorials = 1! + 4! + 5! = 1 + 24 + 120 = 145 Input : n = 534 Output : No
1) Initialize sum of factorials as 0. 2) For every digit d, do following a) Add d! to sum of factorials. 3) If sum factorials is same as given number, return true. 4) Else return false.
An optimization is to precompute factorials of all numbers from 0 to 10.
This article is contributed by Pramod Kumar. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Check if N is Strong Prime
- Program to check whether a number is Proth number or not
- Program to check the number is Palindrome or not
- Program to check if N is a Pentagonal Number
- Program to check for Peterson number
- Program to check Plus Perfect Number
- Program to check if a number is divisible by any of its digits
- Recursive program to check if number is palindrome or not
- Program to check if a given number is Lucky (all digits are different)
- Program to check if a number is divisible by sum of its digits
- Check whether all the rotations of a given number is greater than or equal to the given number or not
- Check if a number is divisible by all prime divisors of another number
- Check if a number with even number of digits is palindrome or not
- Program to check for ISBN
- Program to check Involutory Matrix