print('Index Pattern Value')
for i in range(low, end):
    val = format.format(i)
if val.count('1') == oneBits:
    print('%5d %s %5d' % (index, val, i))
index += 1
Finding permutation of a set of 0 and 1, given index with O(N)