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:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Check if given coins can be used to pay a value of S
- Check whether a given number is even or odd
- Check whether it is possible to convert A into B
- Check if is possible to get given sum from a given set of elements
- Check whether the exchange is possible or not
- Check n^2 - m^2 is prime or not
- Check divisibility by 7
- Check if N is Strong Prime
- Check if two numbers are co-prime or not
- Check if N is a Factorial Prime
- Check if given string contains all the digits
- Check if the sum of digits of N is palindrome
- Check whether a + b = c or not after removing all zeroes from a,b and c
- Check if a number can be expressed as a^b | Set 2
- Check if an Octal number is Even or Odd
- Check if N-factorial is divisible by X^Y
- Check if the number is divisible 43 or not
- Check if the given number is divisible by 71 or not
- Check if a number is divisible by 47 or not
- Check if the XOR of an array of integers is Even or Odd
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.