Given a number N. The task is to check if the sum of digits of the given number divides the number or not. If it divides it then print YES otherwise print NO.
Input : N = 12 Output : YES Sum of digits = 1+2 =3 and 3 divides 12. So, print YES. Input : N = 15 Output : NO
Extract digits of the number and calculate the sum of all of its digits and check if the sum of digits dives N or not.
Below is the implementation of the above approach:
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- 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 a given number divides the sum of the factorials of its digits
- Count of prime digits of a Number which divides the number
- Check if a M-th fibonacci number divides N-th fibonacci number
- Numbers of Length N having digits A and B and whose sum of digits contain only digits A and B
- Check whether product of digits at even places is divisible by sum of digits at odd place of a number
- Check if the sum of digits of number is divisible by all of its digits
- Highest power of a number that divides other number
- Smallest number with given sum of digits and sum of square of digits
- Minimum digits to be removed to make either all digits or alternating digits same
- Find smallest number with given number of digits and sum of digits
- Find the Largest number with given number of digits and sum of digits
- Find smallest number with given number of digits and sum of digits under given constraints
- Number formed by deleting digits such that sum of the digits becomes even and the number odd
- Greatest divisor which divides all natural number in range [L, R]
- Find the largest composite number that divides N but is strictly lesser than N
- Largest number that divides x and is co-prime with y
- Find maximum power of a number that divides a factorial
- Highest power of two that divides a given number
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.