**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)?



Coin flipping game
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.


