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)
- Highest and Smallest power of K less than and greater than equal to N respectively
- Find the sum of digits of a number at even and odd places
- Count even and odd digits in an Integer
- Program to print Sum of even and odd elements in an array
- Represent N as sum of K even or K odd numbers with repetitions allowed
- Sum of even numbers at even position
- Count number of even and odd elements in an array
- Frequencies of even and odd numbers in a matrix
- Python program to count Even and Odd numbers in a List
- Program to print product of even and odd indexed elements in an Array
- Count Odd and Even numbers in a range from L to R
- Largest Even and Odd N-digit numbers
- Replace the odd positioned elements with their cubes and even positioned elements with their squares
- Find elements of an Array which are Odd and Even using STL in C++
- Increment odd positioned elements by 1 and decrement even positioned elements by 1 in an Array
- C++ program to print all Even and Odd numbers from 1 to N
- Largest Even and Odd N-digit numbers in Hexadecimal Number System
- Count number of even and odd length elements in an Array
- Check whether count of odd and even factors of a number are equal
- Rearrange array by interchanging positions of even and odd elements in the given array
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.