Part of a solution, I'm trying to calculate $(n-1)^2$ in $mod\ n$ when $n\in\mathbb{N}$. What I tried to do:
$$ (n-1)^2=(n^2-2n+1)\ (mod\ n)$$
But I'm not sure what to do next. How should I approach this?
Part of a solution, I'm trying to calculate $(n-1)^2$ in $mod\ n$ when $n\in\mathbb{N}$. What I tried to do:
$$ (n-1)^2=(n^2-2n+1)\ (mod\ n)$$
But I'm not sure what to do next. How should I approach this?
$n-1\equiv -1 \pmod n$
So $(n-1)^2 \equiv (-1)^2 \equiv 1\pmod n$.
....
Or $n^2= n*n \equiv 0 \pmod n$. And $-2n\equiv (-2)*n\equiv 0 \pmod n$. ANd $1 \equiv 1\pmod n$.
So $n^2 - 2n + 1 \equiv 0 + 0 + 1 \equiv 1 \pmod n$.
...
You just need to keep is mind for $a\equiv \alpha \pmod n$ and $b \equiv \beta \pmod n$
That $a \pm b\equiv \alpha \pm \beta \pmod n$ and $ab \equiv \alpha \beta \pmod n$ and $ma\equiv m\alpha \pmod n$ and $a^k \equiv \alpha^k \pmod n$ and that $n \equiv 0 \pmod n$.
EVERYTHING falls from that exceedingly nicely.
(In other words nearly all arithmetic distributes over modulus, and that $n$ is equivalent to $0$.)
(So $(n-1)^2$ is over modulus then, under $\mod n$ arithmetic, the same thing as $(-1)^2$.)
(A few things to watch out for. Division doesn't distribute unless divisor and modulus are relatively prime. And the powers of exponents are not actually arithmetic so they don't distribute.)