What is the efficient way to show next binary having n no of 1?

38 Views Asked by At

I need this series of data where n = 4.

111100 111010 111001 110110 110101 110011 101110 101101 101011 100111 011110 011101 011011 010111 001111

All of the above number contains 4 no's of 1

I try to solve problem with hamming weight. But, for a larger no, it is time consuming.

Is there any mathematics by which i can get next number which have n no of 1?