JAVA
java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
public class Program
{
public static void main(String[] args) {
int totalCount = 0;
for (int k = 0; k < 10000; k++) {
Integer i = new Integer(k);
String binary = Integer.toBinaryString(i);
char[] arrs = binary.toCharArray();
int count = 0;
for (int j = 0; j < arrs.length; j++) {
if (arrs[j] == '1') {
count += 1;
}
}
if (count%2==1) {
totalCount +=1;
//System.out.println("Binary number => " + binary + " and Num : " + i);
}
}
System.out.println("Total Number of Odious is " + totalCount);
}
}
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run