Solving, by rearranging and factoring (1), we get
7m=n5+n4+1=n5+n4+n3−(n3−1)=n3(n2+n+1)−(n−1)(n2+n+1)=(n3−n+1)(n2+n+1).
From (1), we know n>1, and when n=2, we get m=2.
Next, consider the case where n>2. We first look at the greatest common divisor of the two expressions on the right side of (2).
==(n3−n+1,n2+n+1)=(n3−n+1−(n2+n+1)(n−1),n2+n+1)(−n+2,n2+n+1)=(−n+2,n2+n+1+(−n+2)(n+3))(−n+2,7).
Thus, (n3−n+1,n2+n+1)∣7.
Combining this with (2), we know that n3−n+1 and n2+n+1 are both powers of 7, and when n⩾3, they are both greater than 7, which implies 72∣(n3−n+1,n2+n+1), leading to a contradiction with the previous result.
In conclusion, the only solution is (m,n)=(2,2).