Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static int digits(int n) {
- int count1 = 0;
- int count2 = 0;
- while (n > 0) {
- int d = n % 10;
- n /= 10;
- if (d % 2 == 0)
- count2++;
- else
- count1++;
- }
- if (count1 == count2)
- return 0;
- if (count1 > count2)
- return 1;
- return 2;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement