Coin flipping game

To complete the proof of Dieter Kadlka: For $n=2^m$, we are looking for $a\neq b< n$ such that $$ b^2+b=a^2+a+l 2^{m+1} $$ for some $l\in \mathbb{N}$ and then $$l 2^{m+1} = (b-a)(b+a+1)$$ Because $b-a$ and $b+a+1$ have different parity, we have (Gauss Lemma) either $2^{m+1}|(b-a)$ or $2^{m+1}|(b+a+1)$ which is impossible since $2^{m+1}>|a|+|b|$


Only a partial answer: Assume that $n$ is not a power of $2$. Then there is a prime $p | n$ with $p > 2$. First we consider the case $n = p$. Then for $p = 3$ $\{(k (k+1)/2 \mod 3 \colon k = 0,1,2\} = \{0,1\}$ and $f_p(k) := k(k+1)/2 \mod p$ is not surjective. For $p > 3$ we have $f_p(k) \equiv f(p-k-1) \mod p$, in particular $f_p(1) \equiv f(p-2) \mod p$, hence $f_p$ is not injective. Now for $n$ as above with prime factor $p > 2$ consider the natural map $\pi \colon \mathbb{Z}/(n) \to \mathbb{Z}/(p)$ ($(n)$ the ideal generated by $n$). If $f_n$ is surjective, then $f_p = \pi \circ f_n$ must be surjective, which is false. Hence if $n$ is not a power of $2$ the map $f_n$ is not bijective.