Delhi's Odd Even

Why my Test cases are not be passed but output is true

Hey @shardul15
your logic is wrong

  • Take input of the Number.
  • Declare two variables to store the sum of even numbers and odd numbers.
  • Extract digit one by one ( by % 10).
    1. Check if the number is even or odd.

    2. If even add the number in the variable storing even sum.

  1. Othewise add it in the variable storing odd sum.
  • After the loop, Check if the even sum is divisible by 4 || if the odd sum is divisible by 3.
    1. If True, print Yes.

    2. otherwise print No.

@Monu-Singh-480654572341490 My logic is same as you said
import java.util.*;

public class Main {
public static void main(String args[]) {
Scanner scn = new Scanner(System.in);
int n = scn.nextInt();
if (n <= 1000) {
while (n > 0) {
int num = scn.nextInt();
if (num >= 0 && num <= 1000000000) {
int esum = 0;
int osum = 0;
while (num > 0) {
int rem = num % 10;
if (rem % 2 == 0) {
esum += rem;
} else {
osum += rem;
}
num = num / 10;
}

				if (esum % 4 == 0 || osum % 3 == 0) {
					System.out.println("Yes");
				} else {
					System.out.println("NO");
				}
			}
			n--;
		}
	}

}

}

System.out.println(“No”); instant of System.out.println(“NO”);

1 Like

@Monu-Singh-480654572341490 thanks sir