I am looking for a formula to calculate the number of combinations possible for 5 bits with the constraint that 2 bits should always be on (1) and 3 off (0). e.g. 10010, 11000, 00101,... etc.
Any ideas?
CodePudding user response:
You have 5 choices for the position of the first (1)
bit and after that you have 4 choices for the position of the second (1)
bit. It gives total 5*4
variants, but this way we counted each combination twice, hence we should divide this value by 2
.
The formula is 5*4/2=10
.