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:
- Check whether it is possible to convert A into B
- Check whether a given number is even or odd
- Check if given coins can be used to pay a value of S
- 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 n^2 - m^2 is prime or not
- Check whether XOR of all numbers in a given range is even or odd
- Check whether the given array is perfect or not
- Check if the given vectors are at equilibrium or not
- Check if two numbers are co-prime or not
- Check for Amicable Pair
- Check if it is possible to redistribute the Array
- Check if all occurrences of a character appear together
- Check if a number is divisible by 41 or not
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.