PY
py
1
2
3
4
5
6
7
8
# Printiong numbers with an odd number of one in their binary expansion
# The idea is to minimize the slow parts (printing and intepreting instructions)
# Using a fast method to calculate bit parity
# Limiting factor is printing - works up to n=2000 - 3000
# Fast parity cakculation using (x6996>>(i^(i>>4)^(i>>8)^(i>>12))&1 works for n<65 536
# VcC 2017
print(*[i for i in range(5000) if ((0x6996>> ((i^(i>>4)^(i>>8)^(i>>12))&0xf)) & 1)][:(lambda n:(n&1)+(n>>1))(int(input()))],sep=",")
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run