### m.khooryani's blog

By m.khooryani, history, 6 years ago,
        int limit = 1 << n;
for (int i = 0; i < limit; i++) {
if (Integer.bitCount(i) >= 3) {
System.out.println(i);
}
}


• +3

 » 6 years ago, # |   +27 There's technically no asymptotically better way. Note that the number of integers in that range that have bitCount < 3 is So the total number of integers you would be printing out is O(2n) - O(n2) = O(2n),  which is at least necessary asymptotically.