Given an integer N and the task is to check whether N is a Factorion or not. A Factorion is a number which is equal to the sum of the factorials of its digits.
Input: N = 40585
4! + 0! + 5! + 8! + 5! = 40585
Input: N = 234
2! + 3! + 4! = 32
Approach: Create an array fact of size 10 to store the factorials of all possible digits where fact[i] stores i!. Now for all the digits of the given number find the sum of factorials of the digits using the fact array computed earlier. If the sum if equal to the given number then the number is a Factorion else it is not.
Below is the implementation of the above approach:
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Check n^2 - m^2 is prime or not
- Check whether it is possible to convert A into B
- Check whether a given number is even or odd
- Check whether the exchange is possible or not
- Check if is possible to get given sum from a given set of elements
- Check divisibility by 7
- Check if given coins can be used to pay a value of S
- Check if a number is divisible by 47 or not
- Check if the XOR of an array of integers is Even or Odd
- Check if N-factorial is divisible by X^Y
- Check if a number is divisible by 41 or not
- Check if a number is divisible by 23 or not
- Check if it is possible to redistribute the Array
- Check if the array is beautiful
- Check for Amicable Pair
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 Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.