Let $g : \mathbb{N} \to \mathbb{N}$ be a function satisfying:
$g(xy) = g(x)g(y)$ for all $x, y \in \mathbb{N}$,
$g(g(x)) = x$ for all $x \in \mathbb{N}$, and
$g(x) \neq x$ for $2 \leq x \leq 2018$.
Find the minimum possible value of $g(2)$.
We claim that the minimum possible value of $g(2)$ is $1013$.
From the first condition, we can see that $g(p_{1}^{e_{1}}p_{2}^{e_{2}}\cdots p_{m}^{e_{m}})=g(p_{1})^{e_{1}}g(p_{2})^{e_{2}}\cdots g(p_{m})^{e_{m}}$
Therefore, we only need to construct $g(p)$ for every prime $p$.
If for some prime $p$ $g(p)$ is composite, write $g(p)=mn(m,n>1)$.
Then $g(mn)=p=g(m)g(n)$, so $g(m)=1$ or $g(n)=1$, contradiction.
Therefore if $p$ is prime, $g(p)$ is also prime.
If $g(2)\leq 1009$, then let $g(2)=q$. $g(2q)=g(2)g(q)=q\cdot 2=2q$, and $2\leq 2q\leq 2018$, so contradiction.
Therefore $g(2)\geq 1010$, and since $1013$ is the smallest prime greater than $1010$, $g(2)\geq 1013$.
Now we prove there exists a function $g$ satisfying all the conditions such that $g(2)=1013$.
For primes $p$ smaller than $2018$, let $g(p)$ be an arbitrary prime bigger than $2018$ such that $f(2)=1013$ and the values of $g$ are all distinct.
Now for $p$ smaller than $2018$, if $g(p)=q$, then let $g(q)=p$ also. For any remaining prime $r$, let $g(r)=r$.
We can easily see that this $g$ satisfies the condition. $\blacksquare$