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:
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Check n^2 - m^2 is prime or not
- Check if given coins can be used to pay a value of S
- 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 divisibility by 7
- Check if is possible to get given sum from a given set of elements
- Check whether a number is semiprime or not
- Check if it is possible to redistribute the Array
- Check whether (i,j) exists such that arr[i] != arr[j] and arr[arr[i]] is equal to arr[arr[j]]
- Check whether bitwise OR of N numbers is Even or Odd
- Check whether the given integers a, b, c and d are in proportion
- Check if the number is balanced
- Check if a HexaDecimal number is Even or Odd
- Check if the XOR of an array of integers is Even or Odd
- Check whether a number is Emirpimes or not
- Check if N-factorial is divisible by X^Y
- Check if the given number is divisible by 71 or not
- Check if the number is divisible 43 or not
- Check if a number is divisible by 47 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.