g:N→N
g(3n+1)=3n+2
g(3n+2)=3n+3
g(3n+3)=3n+1
g(x)={\begin{matrix}\begin{matrix}x+1; & x=3k+1 \\ x+1; & x=3k+2 \\ x-2; & x=3k+3\end{matrix}\end{matrix}\begin{matrix} \\ \\ \end{matrix}
g(g(x))={\begin{matrix}\begin{matrix}x+2; & x=3k+1 \\ x-1; & x=3k+2 \\ x-1; & x=3k+3\end{matrix}\end{matrix}\begin{matrix} \\ \\ \end{matrix}
g(g(g(x)))={\begin{matrix}x; & x=3k+1 \\ x; & x=3k+2 \\ x; & x=3k+3\end{matrix}\begin{matrix} \\ \\ \end{matrix}\begin{matrix} \\ \\ \end{matrix}
If f:N→N,f is a one-one function such that f(g(x))=f(x)⇒g(x)=x, which is not the case
If f:N→N,f is an onto function such that f(g(x))=f(x) one possibility is
f(x)={\begin{matrix}n; & x=3n+1 \\ n; & x=3n+2 \\ n; & x=3n+3\end{matrix};n\in N
Here f(x) is onto, also f(g(x))=f(x)∀x∈N