For each positive integer $m$, let $f_m:Z_m\to Z_m$ be given by
$$
f(x)
=
\Bigl(
{\small{\frac{x^2+x}{2}}}
\Bigr)
{\,\text{mod}\,}
m
$$
Claim:$\;f_m$ is injective if and only if $m$ is a power of $2$.
Proof:
First assume $m$ is not a power of $2$.
We want to show that $f_m$ is not injective.
Suppose instead that $f_m$ is injective.
Let $n > 1$ be an odd divisor of $m$.
Then $2$ is a unit in $Z_n$.
Since $f_m$ is injective, $f_m$ is surjective, hence $f_n$ is surjective.
Since $f_n$ is surjective, $f_n$ is injective, contrary to
$$
f_n(n-1)
=
(2^{-1})(n^2-n)
=
0
=
f_n(0)
$$
hence $f_m$ is not injective, as was to be shown.
Next assume $m$ is a power of $2$.
We want to show that $f_m$ is injective.
The injectivity of $f_1$ is immediate, so assume $m > 1$.
Since $m$ is a power of $2$, so is $2m$.
It follows that all odd integers are invertible mod $2m$.
Now suppose $f_m(x)=f_m(y)$ for some $x,y\in\{0,...,m-1\}$ with $x > y$.
Our goal is to derive a contradiction.
From $f_m(x)=f_m(y)$ we get
\begin{align*}
&
{\small{\frac{x^2+x}{2}}}\equiv{\small{\frac{y^2+y}{2}}}\;(\text{mod}\;m)
\\[4pt]
\implies\;&
x^2+x\equiv y^2+y\;(\text{mod}\;2m)
\\[4pt]
\implies\;&
(x^2+x)-(y^2+y)\equiv 0\;(\text{mod}\;2m)
\\[4pt]
\implies\;&
(x-y)(x+y+1)\equiv 0\;(\text{mod}\;2m)
\\[4pt]
\end{align*}
Consider two cases . . .
Case $(1)$:$\;x-y$ is even.
Then $x+y+1$ is odd, so $x+y+1$ is invertible mod $2m$.
Also we have $1\le x-y\le m-1$, so $x-y$ is not divisible by $2m$.
But then
\begin{align*}
&
(x-y)(x+y+1)\equiv 0\;(\text{mod}\;2m)
\\[4pt]
\implies\;&
x-y\equiv 0\;(\text{mod}\;2m)
\\[4pt]
\end{align*}
contradiction.
Case $(2)$:$\;x-y$ is odd.
Then $x-y$ is invertible mod $2m$.
Also we have $2\le x+y+1\le 2m-2$, so $x+y+1$ is not divisible by $2m$.
But then
\begin{align*}
&
(x-y)(x+y+1)\equiv 0\;(\text{mod}\;2m)
\\[4pt]
\implies\;&
x+y+1\equiv 0\;(\text{mod}\;2m)
\\[4pt]
\end{align*}
contradiction.
Thus both cases yield a contradiction.
It follows that $f_m$ is injective.
This completes the proof.
$$\bmod {\rm odd}\ m!:,\ (x!+!1)x/2\equiv c,\overset{8(\ \ )+1}\Longrightarrow, (2x!+!1)^2\equiv \color{#0a0}{8c!+!1}\qquad\qquad\qquad$$
so it has no roots if the $\rm\color{#0a0}{discriminant}$ is $\rm\color{#c00}{nonsquare},,$ i.e. $,\color{#0a0}{8c!+!1} = \color{#c00}b,,$ i.e. if $,c\equiv (b!-!1)/8\ \ $
– Bill Dubuque Apr 25 '24 at 15:49