Find integral solutions of $a^{b^2}=b^a$ For a number theory problem, I have to figure out all couples $(m,n)$ of positive integers which verify the equation 

$$m^{n^2}=n^m$$

I just don't know what to do.
Thanks !
 A: We are required to solve $m^{n^2}=n^m$ in positive integers. Take $g=\gcd(m,n)$. Then, we define $m=gm_1$ and $n=gn_1$ where $m_1$ and $n_1$ are relatively prime positive integers. Substituting:-
$$(gm_1)^{g^2n_1^2}=(gn_1)^{gm_1} \implies (gm_1)^{gn_1^2}=(gn_1)^{m_1}$$
As $\gcd(m_1,n_1)=1$, we must have one of them to be $1$ in the above equation.
Case 1: $m_1=1$
Substituting, we yield:-
$$g^{gn_1^2}=gn_1 \implies g^{gn_1^2-1}=n_1$$
If $n_1>1$, then it clearly follows that $g^{gn_1^2-1}>2^{n_1^2-1}>2^{n_1}>n_1$. Thus, we must have $n_1=1$ and $g=1$. This gives us $(m,n)=(1,1)$.
Case 2: $n_1=1$, $m_1>1$
Substituting, we yield:-
$$g^g \cdot m_1^g=g^{m_1} \implies m_1^g=g^{m_1-g}$$
Thus, we can see that $m_1-g>0 \implies m_1>g$. As the base is greater on one side, the exponent must be larger on the other side. Thus, $m_1-g>g$. It follows that $g^g \mid g^{m_1-g} \implies g^g \mid m_1^g \implies g \mid m_1$. Let $m_1=gm_2$ where $m_2$ is a positive integer. Then:-
$$(gm_2)^g=g^{gm_2-g} \implies gm_2=g^{m_2-1} \implies m_2=g^{m_2-2}>2^{m_2-2}$$ 
This shows that $2 < m_2 \leqslant 4$. If $m_2=3$, we get $g=3$ which gives $(m,n)=(27,3)$. Else, if $m_2=4$, we get $g=2$ which gives $(m,n)=(16,2)$.
Therefore, the solutions are:-
$$(m,n)=(1,1),(16,2),(27,3)$$
