Given a number N represented as a string The task is to print ‘Yes’ if the sum of digits is even and is divisible by 4 or if the sum of digits is odd and is divisible by 3 otherwise ‘No’.
Input: 12345 Output: Yes Input: 894561 Output: Yes
Below is the step by step algorithm:
- Calculate sum of all digits.
- If the sum is even:
- Check if the sum is divisible by 4
- Else if the sum is odd:
- Check if it is divisible by 3.
- Print Yes, if any of the case in step 2 or step 3 satisfies otherwise print No.
Time Complexity :O(n)
- Program to check if a number is divisible by sum of its digits
- Minimum number of digits to be removed so that no two consecutive digits are same
- GCD of digits of a given number
- Print numbers with digits 0 and 1 only such that their sum is N
- Smallest odd number with N digits
- Smallest Even number with N digits
- Sum of digits of a given number to a given power
- Absolute difference between the first X and last X Digits of N
- Spy Number (Sum and Products of Digits are same)
- Sum of digits written in different bases from 2 to n-1
- Count even and odd digits in an Integer
- Number of digits in 2 raised to power n
- Check if the frequency of all the digits in a number is same
- Find the sum of digits of a number at even and odd places
- Check if the sum of digits of a number N divides it
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.