Appendix A. Proof of Theorem 3.4
For a positive integer we denote by the parity of ( = even, = odd), and by the sequence of the first parities.
Remark A.1
If and have the same parity, then Hence, as long as the parities agree, after steps we have where is the number of odd steps among the first .
Lemma A.2
If , then .
Proof. We argue by induction on , showing that and that divides . For , divides and, since , and have the same parity. If the claim holds for , the parities of and agree and, by Remark A.1, the difference is obtained from by multiplying by or by ; hence it is divisible by , and in particular and have the same parity.
∎
Lemma A.3
If , then .
Proof. Let be the highest power of 2 dividing : since , we have , and with odd. Suppose, for a contradiction, that the first parities agree. Then in particular the first agree, and (A.1) with gives which is odd. Hence and have different parities, that is with : a contradiction.
∎
Proof of Theorem 3.4. By Lemma A.2, the sequence depends only on the remainder of modulo : this defines a function from the set of the residue classes to the set of the sequences of length . By Lemma A.3 this function is injective. An injective map between two finite sets with the same number of elements is also surjective, hence bijective: every parity sequence occurs for exactly one residue class.
∎