Thailand MO problem Find all pairs of positive integers (,) satisfying the equation
$m!+n!=m^n+1$
Here’s my try…
By taking mod $m$ we get
$n! \equiv 1 \mod m$.
So we know that $m>n$ (if $m\leq n$ then $m \mid n!$)
then $n \mid m!$
Taking mod $n$ we get
$m^{n}  \equiv -1 \mod n$
let $o$ be the order of $m$ modulo $n$.
Then  $o \mid 2n$ but $o \nmid n$.
And I have no idea what I should do next.
 A: You have the right general idea in your first part. However, with the equation
$$m!+n!=m^n+1 \; \; \to \; \; n!\left(\frac{m!}{n!}+1\right) = m^n + 1 \tag{1}\label{eq1A}$$
a small issue is that if $m = 1$, then $n! = 1 \; \to \; n = 1$, so your conclusion of $m \gt n$ should more generally be $m \ge n$ instead. Nonetheless, this still means $\frac{m!}{n!}$ in the RHS above is always an integer.
Consider the results for each integer value of $n \ge 1$. First, with $n = 1$, \eqref{eq1A} becomes $m! + 1 = m + 1 \; \to \; m! = m$, with solutions $m = 1$ and $m = 2$, as Suzu Hirose's comment already indicated.
Next, with $n = 2$, \eqref{eq1A} becomes $m! + 2 = m^2 + 1 \; \to \; 1 = m(m - (m-1)!)$, which has no solutions.
With $n \ge 3$, note \eqref{eq1A} shows $3 \mid m^n + 1$, so $n$ must be odd (since $m^n \equiv 0, 1 \pmod{3}$ for $n$ even). Using the Lifting-the-exponent lemma (LTE lemma), we get
$$\nu_2(m^n + 1) = \nu_2(m^n - (-1)^n) = \nu_2(m - (-1)) = \nu_2(m + 1) \tag{2}\label{eq2A}$$
Also, since $m \equiv 2 \pmod{3} \; \to \; 3 \mid m + 1$, the LTE lemma gives here that
$$\nu_3(m^n + 1) = \nu_3(m + 1) + \nu_3(n) \tag{3}\label{eq3A}$$
Thus, for $n = 3$, \eqref{eq3A} shows that $\nu_3(m^n + 1) \ge 2$. Since $m+1$ is even and is a multiple of $3$, it's a multiple of $6$. However, since $\nu_3(3!) = 1$, then $\nu_3\left(\frac{m!}{n!}+1\right) \ge 1$ so $m \lt 6$ (since, otherwise, $3 \mid \frac{m!}{n!}$). Thus, $m = 5$ is the only possible value, with Jyrki Lahtonen's comment indicating this is another solution.
Note for each increase in $n$ by $2$, there's at least one more factor of $2$ in $n!$, so \eqref{eq2A} shows the minimum value of $m$ must basically at least double. For $n = 5$, since $\nu_2(5!) = 3$ and $\nu_3(5!) = 1$, the minimum ratio of $m$ to $n$ is $\frac{2^3(3) - 1}{5} = \frac{23}{5}$ so, for $n \ge 5$, we have
$$\frac{m}{n} \gt 4.5 \; \; \to \; \; n \lt \frac{m}{4.5} \tag{4}\label{eq4A}$$
From the first part of \eqref{eq1A}, we have
$$m! \lt m^n \; \; \to \; \; \ln(m!) \lt n\ln(m) \tag{5}\label{eq5A}$$
Using Stirling's approximation lower bound for $m \ge 1$, and removing a few factors, gives
$$\left(\frac{m}{e}\right)^{m} \lt \sqrt{2\pi m}\left(\frac{m}{e}\right)^{m}e^{\frac{1}{12m+1}} \lt m! \tag{6}\label{eq6A}$$
Next, taking the natural log of \eqref{eq6A} and using \eqref{eq5A} gives
$$m\ln(m) - m \lt n\ln(m) \; \; \to \; \; (m - n)\ln(m) \lt m \tag{7}\label{eq7A}$$
From \eqref{eq4A}, we have $m - n \gt 0.7(m)$, and $m \ge 23 \; \to \; \ln(m) \gt 3.1$, so the LHS of the second part of \eqref{eq7A} is greater than $3.1(0.7)m = (2.17)m$. However, this contradicts the RHS, so there are no solutions for any $n \ge 5$.
Thus, in summary, the solutions are just $(m,n) \in \{(1,1), (2,1), (5,3)\}$.
