Only One Pair of Distinct Positive Integers Satisfy The Equation n^m = m^n

A beautiful analytic proof of a number theoretic result

Keith McNulty
3 min readMar 18


For today’s interesting problem, we are looking to find all positive integer pairs n and m which satisfy the equation above, when n and m are distinct. If we play around with small n and m we can quickly see that 2⁴ = 16 = 4² , so the pair 2 and 4 are certainly one solution.

It turns out that the pair 2 and 4 is in fact the only such solution. The more interesting aspect of this problem is how we prove that this is the only solution. The proof involves an analysis of a function which is continuous in the positive domain, rather than discrete number theory. Here it is.

Turning the problem into a function to analyze

If we do some simple manipulation of our equation through taking natural logarithms, we can state it in an alternate form, as follows:

So a solution to our original equation represents two distinct positive integers n and m for which this function has the same value:

Sketching the function

Let’s sketch this function and see what it looks like. First, we can differentiate it and set the derivative to zero to determine if there are any stationary points on the curve.

This only solution to this is lnx = 1, so the function has a single stationary point at x = e, y = 1/e. Note also that

  • At x = 1, y = 0
  • As x approaches zero, lnx approaches -∞ and so y approaches -∞ also.
  • As x gets large, and because lnx increases much more slowly than x, we have that y approaches zero.

Putting these facts together, we can conclude that our stationary point is a maximum, and we can sketch our function as follows, with the function crossing the x axis at x = 1:



Keith McNulty

LinkedIn Top Voice in Tech. Expert and Author in Applied Mathematics, Data Science, Statistics. Find me on Twitter or