Prove that $a \equiv b \pmod{1008}$ 
Suppose that the positive integers $a$ and $b$ satisfy the equation $$a^b-b^a = 1008.$$ Prove that $a \equiv b \pmod{1008}$.

Taking the equation modulo $1008$ we get $a^b \equiv b^a \pmod{1008}$, but I didn't see how to use this to get that $a \equiv b \pmod{1008}$.

We prove that $a = 1009, b = 1$ is the only solution.
First we restrict attention to the case in which $a, b \geq 3$.
We can rewrite the equation as
$$\frac{\log a}{a} - \frac{\log b}{b} = \frac{\log\left(1 + \frac{1008}{b^a}\right)}{ab}.$$
Let $f(x) = \frac{\log x}{x}$. We have $f'(x) = \frac{1 - \log x}{x^2} < 0$, so $f(x)$ is decreasing on $[3,+\infty)$. Therefore we have $b > a$.
By the mean value theorem, there is some $c \in (a,b)$ such that
$$\frac{\log a}{a} - \frac{\log b}{b} = (b - a)\frac{\log c - 1}{c^2} \geq \frac{\log 3 - 1}{b^2}.$$
On the other hand, we have 
$$\frac{\log\left(1 + \frac{1008}{b^a}\right)}{ab} \leq \frac{1008/b^a}{ab} = \frac{1008}{ab^{a+1}}.$$
Therefore 
$$ab^{a-1} \leq \frac{1008}{\log 3 - 1} < 10222.$$
Consequently, we must have $a \leq 5$, and:


*

*If $a = 3$, then $4 \leq b \leq 58$.

*If $a = 4$, then $5 \leq b \leq 13$

*If $a = 5$, then $b = 6$.


But all of these cases are impossible.


*

*$5^6 - 6^5 \ne 1008$, so $a \ne 5$.

*When $a = 4$, we have $4^b - b^4 = 1008$. $1008$ is equal to $16$ modulo $32$, so we must have $b = 2$ modulo 4. But $b = 6$ and $b = 10$ are not solutions.

*When $a = 3$, we have $3^b - b^3 = 1008$. Since $b > 3$, we have $b^3 = 18$ modulo 27, but this equation has no solutions.
Other cases
When $b = 1$, we have only the solution $a = 1009$.
When $b = 2$, we have $a^2 > 2^a + 1$, which never occurs.
When $a = 1$, there are obviously no solutions.
When $a = 2$, we have $2^b - b^2 = 1008$. If $x_n = 2^n - n^2$, then $x_{n + 1} - x_n = 2^n - (2n + 1) > 0$ for $n \geq 3$, so the sequence $x_n$ is increasing from $n \geq 3$. We have $x_{10} < 1008 < x_{11}$, so there are no solutions for $a = 2$.
