Modular quadratic equation question- Where did I go wrong? \begin{gather}
\frac{N^2+N}{2} \equiv 0 \pmod 4 \\
N^2+N\equiv 0\\
(N+\frac{1}{2})^2-\frac{1}{4}\equiv 0\\
4(N+\frac{1}{2})^2-1\equiv 0\\
2^2(N+\frac{1}{2})^2\equiv 1\\
(2N+1)^2\equiv 1 \\
2N+1 \equiv 1\\
2N=0\\
N=2,4,6,8...\\
2N+1 \equiv 3\\
2N=2\\
N=1,3,5,7...\\
\end{gather}
In other words I've shown $\forall N >0 \to \frac{N^2+N}{2} \equiv 0 \pmod 4$, which is false e.g. for $N=3$,  $\frac{N^2+N}{2}$ has a remainder of 2
I'd like a correct solution as well. Thanks.
 A: Your first error is that you you scaled by $\,2,\,$ which is not invertible $\!\bmod 4,\,$ so this will not yield an equivalent congruence. Rather, it yields necessary but not sufficient conditions on roots (so possibly  extraneous roots). See here for more on the insufficiency of unidirectional inferences.
To get an equivalent congruence we need to scale the modulus too, since $\,4\mid a/2\iff 8\mid a,\,$ so
$$(n^2+n)/2\equiv 0\!\!\!\pmod{4}\iff n^2+n\equiv 0\!\!\!\pmod{8}\qquad$$
Now we can complete the square as you did, but since this too involves scaling the modulus, this will end up being fruitless, leading back to where we started, namely
$$\begin{align} n^2+n&\equiv 0\pmod{8}\\
\iff\ \ \ \ \ \ \ 4n^2+4n&\equiv 0\pmod{32}\\
\iff 4n^2+4n+1&\equiv 1\pmod{32}\\
\iff \ \ \ \ \ \, \color{#c00}{(2n+1)^2}&\:\color{#c00}{\equiv 1}\pmod{32}\\
\iff (2n)(2n+2)&\equiv 0\pmod{32}\\
\iff\ \ \ \ \ \ \  n(n+1)&\equiv 0\pmod{8}
\end{align}\qquad$$
where we solved $\,\color{#c00}{a^2\equiv 1}\,$ by factoring the difference of squares $\,0\equiv a^2-1\equiv (a-1)(a+1).\,$  You can't simply take square roots as you did, e.g. $\,x^2\equiv 1\pmod{8}\,$ has $4$ roots $\,x\equiv 1,3,5,7$.
Instead, by $\,n,\,n\!+\!1\,$ coprime, $\,8\mid n(n\!+\!1)\iff 8\mid n\,$ or $\,8\mid n\!+\!1,\,$ thus we conclude that  $\,n(n+1)/2\equiv 0\pmod{4}\iff n\equiv 0,7\pmod{8}$
Finally, beware that modular fractions are well-defined (uniquely exist) only when they are writable with denominator coprime to the modulus, when $\,a/b := ab^{-1}.\,$ For more on modular fractions see here and here.
A: What you did incorrectly is basically explained in Peter's answer, and several question comments. Note, though, the more general issue when manipulating congruences, since you are really dealing with integers, is that involving "fractions" of the form $\frac{p}{q}$ where $\gcd(p,q) = 1$, really means the division by $q$ is multiplying by its modulo multiplicative inverse, i.e., $q^{-1}$. However, only integers which are relatively prime to the modulus have inverses. Since $\gcd(4, 4) = 4 \neq 1$ and $\gcd(4, 2) = 2 \neq 1$, neither $2$ nor $4$ have an inverse in modulo $4$, so while working in that modulus you can't, in general, just "divide" by either value, e.g., $\frac{1}{2}$ and $\frac{1}{4}$ don't make sense.
As for how to correctly solve your congruence equation, note for any solution $N$, there's some integer $j$ where
$$\begin{equation}\begin{aligned}
& \frac{N^2 + N}{2} \equiv 0 \pmod{4} \iff \frac{N^2 + N}{2} = 4j \iff \\
& N^2 + N = 8j \iff N^2 + N \equiv 0 \pmod{8}
\end{aligned}\end{equation}\tag{1}\label{eq1A}$$
Due to $N$ and $N + 1$ being relatively prime to each other, with one being odd and one being even, then since $8 = 2^3$ has only prime factors of $2$, this then gives
$$\begin{equation}\begin{aligned}
& N(N + 1) \equiv 0 \pmod{8} \implies \\
& (N \equiv 0 \pmod{8}) \lor (N + 1 \equiv 0 \pmod{8}) \implies \\
& N \equiv 0, 7 \pmod{8}
\end{aligned}\end{equation}\tag{2}\label{eq2A}$$
This means the allowed values for $N$ are $N = 8k$ and $N = 8k + 7$ for any $k \in \mathbb{Z}$.
A: In arithmetic mod $4$, you cannot divide by $4$ or $2$. It is like dividing by $0$ in normal arithmetic; you can write the expression but there is no number that is equal to it.
If you divide and multiply by zero you can prove that all numbers are equal. This is of course inconsistent with our normal arithmetic, and also with modular arithmetics. The reason is that you cannot divide by zero.
If you allow division by zero you get the uninteresting arithmetic where there is only a single number.
Note that the second line is a legal equation, and its solutions, by trial and error, are $3$ and $4$.
Your example is interesting in the way it disguises $0$ as $4$, and also as $2$, since $2=\sqrt{4}=\sqrt{0}=0$.
I hadn't seen an example like this using modular arithmetic.
A: $(2N+1)^{2} \equiv 1  $
$2N+1 \equiv 1$
This step is wrong, for example: $(2*3+1)^2 \equiv 1$.
