Given a number A that increases after a number B has cycled through a range of values (for example, 1 to 4, like below), I'd like to calculate a number C that increases when value B is half way through the cycle.
How can I calculate this?
Given a number A that increases after a number B has cycled through a range of values (for example, 1 to 4, like below), I'd like to calculate a number C that increases when value B is half way through the cycle.
How can I calculate this?
If $M$ is the cycle and $M$ is an even number than there is an $K$ so that $M = 2K$.
By division algorithm for any integer $n$ we have $n = qM + r$ where $r$ is the remainder after dividing by $M$ and $n = pK + s$ where $s$ is the remainder after dividing by $K$.
Your sequences are $A_n = q+1$ and $B_n = r$ if $r\ne 0$ and $M$ if $r=0$ and $C_n = p + 1$.
Or you can write it as $A_n = \lfloor \frac nM \rfloor + 1$ and $B_n =\lfloor \frac {2n}M\rfloor$+1. (This will actually work if $M$ is odd.)