Alternative solution would be a proof by induction. Depending on n, there are two distinct cases: either \( p_n = p_{n-1} -1 \) and \( q_n = q_{n-1} + 1 \) ["inside" the subsequence], or \( p_n = q_{n-1} + 1 \) and \( q_{n} = p_{n-1} = 1 \) [at the "edge" between two subsequences].
It's easy to check that in both of those cases, from the assumption \( n-1 = f(p_{n-1}, q_{n-1}) \) it follows that \( n = (n-1) + 1 = f(p_n, q_n) \) (and of course for n=1 the formula works as well).
@krzyz
Its a bug and i think i fixed it for the next release.
@Placholdr @eqyo
@Placholdr @eqyo
Oops looks like qoto latex rendering doesn't like my formulas, I either get "[Math Processing Error]" or the subscripts explode in size. @freemo, do you know if that's a bug or a limitation of latex rendering here? (Or have I made some typo?)