## Help with simple bit of (binary?) mathematics

Jun 19 2010 | 2:46 pm

A drummer plays a basic groove for one bar, then plays a variation in bar two. In bar three she goes back to the basic groove, then plays a different variation in bar four. Then she reapeats all of the above for the fifth to seventh bars, playing a new variation in bar eight... and so on.

If we tabulate this so far, labelling the bars from one to eight and the variations as 0, 1 and 2, then we get this;

bar var bin
1 0 0001
2 1 0010
3 0 0011
4 2 0100
5 0 0101
6 1 0110
7 0 0111
8 3 1000

What is the formula (or patch) which would allow one to calculate which variation to play based on the bar number? The only insight I have so far is that if you write out the bar numbers in binary as in the third column, then the number of the variation is given by where the rightmost '1' is; in other words, in bar 7 the rightmost '1' is in the 0th column = var 0, in bar 8, the rightmost '1' is in the 3rd column = var 3.

I've been messing around with all sorts of stuff, and I just can't get it; I know the answer to this must be some *really simple* bit of maths which I just can't see...

Thanks