Given an integer N, the task is to check whether N divides the sum of the factorials of its digits.
Input: N = 19
1! + 9! = 1 + 362880 = 362881 which is divisible by 19.
Input: N = 20
0! + 2! = 1 + 4 = 5 which is not divisible by 20.
Approach: First, store the factorials of all the digits from 0 to 9 in an array. And, for the given number N check if it divides the sum of the factorials of its digits.
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.
- Find two co-prime integers such that the first divides A and the second divides B
- Count of triplets (a, b, c) in the Array such that a divides b and b divides c
- Check if the sum of digits of a number N divides it
- Find last two digits of sum of N factorials
- Check if the sum of digits of number is divisible by all of its digits
- Sum of the digits of square of the given number which has only 1's as its digits
- Count of prime digits of a Number which divides the number
- Find N numbers such that a number and its reverse are divisible by sum of its digits
- Numbers with sum of digits equal to the sum of digits of its all prime factor
- Minimum number of Factorials whose sum is equal to N
- Find the unit place digit of sum of N factorials
- Find sum of factorials in an array
- Sum of factorials of Prime numbers in a Linked list
- Smallest N digit number with none of its digits as its divisor
- Check if a M-th fibonacci number divides N-th fibonacci number
- Trailing number of 0s in product of two factorials
- Find smallest number with given number of digits and sum of digits under given constraints
- Numbers of Length N having digits A and B and whose sum of digits contain only digits A and B
- Program to check if a number is divisible by sum of its digits
- Count natural numbers whose factorials are divisible by x but not y
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.