Find all integers $n, n\gt2$ such that $n^{n-2}=x^n$ for some $x$

We can express this alternatively as $n^{n}=n^{2}x^{n}$. So the number raised to the power of itself has to be proportional to some number to the $n$-th power, but cannot be equal, naturally. I am not sure how to tackle the $n^{n}$ expression.

How would one attempt this problem or perhaps similar problems like this involving $n^{n}$ terms?

Thank you in advance!


Let $n$ and $x$ be integers such that $n>2$ and $n^{n-2}=x^n$. Then $n^{n-2}$ is an $n$-th power.

If $n$ is odd then $n$ and $n-2$ are coprime, so $n^{n-2}$ is an $n$-th power if and only if $n$ is an $n$-th power. Of course $n$ is an $n$-th power if and only if $n=\pm1$. This yields two solutions $(n,x)=(1,1)$ and $(n,x)=(-1,-1)$.

If $n$ is even then $n$ and $n-2$ are both even, say $n=2m$ and $n-2=2(m-1)$. Then the equation $n^{n-2}=x^n$ is equivalent to $(2m)^{m-1}=x^m$. As before this implies that $(2m)^{m-1}$ is an $m$-th power, where $m$ and $m-1$ are again coprime. So $(2m)^{m-1}$ is an $m$-th power if and only if $2m$ is an $m$-th power. This happens only if $m=1,2$, yielding the solutions $(n,x)=(2,1)$ and $(n,x)=(4,2)$.