Let $N$ be a composite integer and consider any $x\le N$. The order of $x$ in $\mathbb Z_N$ is the smallest integer $r$ such that $x^r\equiv 1\text{ mod }N$. If $r$ is even, then $r/2$ is an integer and we notice that $$0\equiv x^r-1 =(x^{r/2}-1)(x^{r/2}+1) \mod N.$$ I have two questions:
- Why does this imply that $\gcd(x^{r/2}\pm 1,N)$ are two factors of $N$?
- Why is the only necessary hypothesis (aside that $r$ has to be even) $x^{r/2}\not\equiv -1\text{ mod }N$, instead of also $x^{r/2}\not\equiv 1\text{ mod }N$? I'm assuming we don't want the above equation to be trivially true if one of the factor is zero mod $N$, but then why should we check that only one of them is not zero?