There are times when you need to make sure your counter starts at an odd or even number.
Even is pretty simple - counter = counter + modulus(counter)
. If counter is even it stays, if it's odd it gets incremented by 1.
Odd is a bit more complicated - counter = counter + modulus(counter + 1)
, If counter is odd it stays, if it's even it gets incremented by 1.
if you're in danger of counter being the max value you can always subtract instead.
These basic algorithms should work for any language that has a modulus operator/function.
I've included a simple example in C#.