<s>[INST] Solve the equation in positive integers $k^m+m^n=kmn$ 
Solve the equation in positive integers $$k^m+m^n=kmn$$

My work so far:
1) Let $k=m$. Then 
$$k^k+k^n=k^2n$$
If $k=1$ then $n=2$; if $k=2$ then $n=2$ or $n=3$ 
Let $k\ge 2$.  We see that $n\ge2$.
$$k^{k-2}+k^{n-2}=n$$
2) Let $k=n$. Then $$k^m+m^k=k^2m$$. I find $m=2$, $k=2$ or $k=4$
3) Let $m=n$. Then $$k^m+m^k=km^2$$. Similarly.
 [/INST] Suppose first that $k$ is the largest among $k$, $m$, and $n$.  Then, $$k^m<k^m+m^n=kmn\leq k^3$$ implies that $k>1$ and $m<3$.  If $m=1$, then we have $k+1=kn$, which is not possible (recalling that $k>1$).  If $m=2$, then $k^2+2^n=2kn$ implies that
$$0\leq (k-n)^2=n^2-2^n\,,$$
yielding $n\in \{2,3,4\}$.  Hence, in this case where $k$ is the largest, the solutions in the form $(k,m,n)$ are $(2,2,2)$, $(4,2,3)$, and $(4,2,4)$.  
Now, suppose that $m$ is the largest of the three variables.  Then,
$$m^n<k^m+m^n=kmn\leq m^3 $$
implies that $m>1$ and $n<3$.  We start with the subcase $n=1$, which leads to
$$k^m+m=km\text{ or }k^m = (k-1)m\,.$$
From the equation above, $k-1$ divides $k^m$, which only happens when $k=2$. 
 Nonetheless, this leads to a contradiction $2^m=m$.  Thus, $n=2$ is the only hope here.  Plugging $n=2$ into the original equation, we get
$$k^m+m^2=2km\text{ or }0\leq (m-k)^2=k^2-k^m\,.$$
This proves that $k=1$ or $m=2$.  If $k=1$, then $m=1<2=n$, which is absurd.  Thus, $m=2$ and we obtain $(k,m,n)=(2,2,2)$.
Finally, we assume that $n$ is the largest.  We note that
$$m^n<k^m+m^n=kmn\leq n^3\,.$$
The inequality above implies that $m<4$.  There are a few easy-to-check scenarios listed below.


*

*$m=1$: this case leads to $(k,m,n)=(1,1,2)$.

*$m=2$: this case leads to $(n-k)^2=n^2-2^n$, which, as before, results in possible solutions in the form $(k,m,n)$ being $(2,2,2)$, $(2,2,3)$, and $(4,2,4)$ (recalling the constraint $k\leq n$).

*$m=3$: this case leads to $3^n<k^3+3^n=3kn\leq 3n^2$, or $3^{n-1}<n^2$.  We have immediately that $n=2$, but this contradicts the assumption that $n\geq m=3$.


In summary, there are five solutions $(k,m,n)\in \left(\mathbb{Z}_{>0}\right)^3$ to $k^m+m^n=kmn$.  All solutions in the form $(k,m,n)$ are $(1,1,2)$, $(2,2,2)$, $(2,2,3)$, $(4,2,3)$, and $(4,2,4)$.
</s>