$g(g(n)) = d(n)$ for all $n \in \mathbb{N}^*$ I would like to find all functions $g : \mathbb{N}^* \rightarrow \mathbb{N}^*$ such that : 
$$g(g(n)) = d(n)$$
$d:\mathbb{N}^* \rightarrow \mathbb{N}^*$ denotes the number of positive divisors of $n$. 
Yet I don't really know how to proceed...
Here is what Ive noticed so far : 
- We know that $d(n) = (\alpha +1)\cdot (\alpha_1+1)...$ then there is a link between the prime decomposition of $n$ and the function $g$
 A: Let $a=g(1)$. Then $g(a)=1$ and $d(a)=g(g(a))=a$. Hence $a=1$ or $a=2$.
Similarly, letting $b=g(2)$, we find $g(b)=2$ and $d(b)=g(g(b))=b$. Hence also $b=1$ or $b=2$.
As $d(1)\ne d(2)$, we cannot have $a=b$. Hence $g$ either swaps or keeps both  of $1$, $2$ fixed.
Consider the case that $g(x)=3-x$ for $x\in\{1,2\}$.
Let $c=g(3)$.
Then $g(c)=2$ and $d(c)=g(g(c))=1$, so $c=1$.
Let $x=g(4)$. Then $g(x)=3$. 
But then $d(x)=g(g(x))=g(3)=1$, hence $x=1$, contradicting $g(x)=3\ne 2=g(1)$.
Hence $g(x)=x$ for $x\in\{1,2\}$.
Note that $d(n)<n$ for all $n>2$.
Assume we have a finite set $\{1,2\}\subseteq S\subset\Bbb N^*$ and $g\colon S\to S$ with $g(g(x))=d(x)$ for all $x\in S$, and $g(x)=x$ for $x\in\{1,2\}$.
We can extend this to a larger set:
Let $n=\min(\Bbb N^*\setminus S)$.
Then $d(n)<n$, hence $d(n)\in S$. 
Pick $m$ with either $m\in S$ and $g(m)=d(n)$ or $m\notin S$ and $d(m)=g(d(n))$ (such $m$ certainly exist, for example $m=p^{g(d(n))-1}$ for a large prime $p$; note that $d(n)\ge 2$ and $g(d(n))\ge 2$) and extend $g$ to $S\cup\{n,m\}$ by setting $g(m)=d(n)$, $g(n)=m$. 
By repeating this step, we finally obtain $g\colon\Bbb N^*\to\Bbb N^*$ with $g\circ g=d$.
It is also clear that every such $g$ can be obtained by the method described.
