Solution
= Solution
Define
$$
\boxed{f(x)=a^x\pmod N,\qquad x\in\mathbb Z,}
$$
using the inverse of $a$ for negative $x$. Since $a^r\equiv1$, $f(x+r)=f(x)$. Conversely, if $f(x)=f(y)$ then $a^{x-y}\equiv1$, so the definition of order gives $r\mid x-y$. Two integers in the same block of $r$ consecutive integers cannot differ by a nonzero multiple of $r$. Hence $f$ is one-to-one within each period.