I was following the website for months now... and since i need help.. I'll ask here :D
I need a way (best way) to find all binary representations given the number of ones and the number of bits in the binary.
suppose i have a binary that consists of 4 bits.
2 of these bits should be 1 and the others (other 2) are 0.
how many binary representation can i make?
the answer will be:
1100
1010
1001
0110
0101
0011
how can i generate such a combination...
is there any math formula that can tell me that a number 3 (0011) has 2 ones in its binary?
i know i can convert the number to binary and then count the number of ones in it... is there any faster way to know how many ones does a binary representation of a number has?
i don't care what language is used.. i just need the algorithm...
I need a way (best way) to find all binary representations given the number of ones and the number of bits in the binary.
suppose i have a binary that consists of 4 bits.
2 of these bits should be 1 and the others (other 2) are 0.
how many binary representation can i make?
the answer will be:
1100
1010
1001
0110
0101
0011
how can i generate such a combination...
is there any math formula that can tell me that a number 3 (0011) has 2 ones in its binary?
i know i can convert the number to binary and then count the number of ones in it... is there any faster way to know how many ones does a binary representation of a number has?
i don't care what language is used.. i just need the algorithm...