Coin flipping game Motivation. My elder son played the following game. He had a bunch of coins, all with heads up, arranged in a circle. He flipped one coin, so that it showed tails, then he moved $1$ position clockwise, flipped that coin, then moved $2$ positions clockwise, flipped that coin, then moved $3$ positions clockwise etc. He stopped whenever he reached a coin that was already showing tails.
Informal version of question. For what values of $n$ can you flip the coins in the manner described above so that you end up with all coins showing tails?
Formal version. For any positive integer $n$, let $[n] = \{0,\ldots,n-1\}$. For what values of $n$ is the map $j:[n]\to [n]$ defined by $$k \mapsto \big(k(k+1)/2 \mod n\big)$$ injective (and therefore bijective)?
 A: 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|$
A: 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.
