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
- Spy Number (Sum and Products of Digits are same)
- Print numbers with digits 0 and 1 only such that their sum is N
- Sum of digits of a given number to a given power
- Sum of digits written in different bases from 2 to n-1
- Absolute difference between the first X and last X Digits of N
- Smallest Even number with N digits
- Count even and odd digits in an Integer
- Smallest odd number with N digits
- Find the total Number of Digits in (N!)N
- Check if the sum of digits of a number N divides it
- Check if the frequency of all the digits in a number is same
- Number of digits in 2 raised to power n
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.