# Find all natural numbers $n$ and $m$ for which $n^m=(n-1)!+1$ [duplicate]

Find all natural numbers $$n$$ and $$m$$ for which $$n^m=(n-1)!+1.$$

By the Wilson theorem, $$n$$ is prime. Obviously, $$m < n$$.

For example, some solutions $$(n, m)$$ are $$(2, 1)$$, $$(3, 1)$$ and $$(5, 2)$$.

• If $n > 4$, then $(n-1)|(n-2)!=\frac{n^m-1}{n-1}=1+n+\ldots+n^{m-1}$. Feb 20, 2019 at 17:25
• $1^1\ne 0!+1$? So $(1,1)$ is not a solution. Feb 20, 2019 at 17:26
• @PeterForeman, I fixed, thank you. Feb 20, 2019 at 17:32

You have found all the solutions.

Suppose there is a solution with $$n>5.$$ As you have noted, by Wilson's theorem, $$n$$ is prime. We have $$n^m-1=(n-1)!,$$ and dividing both sides by $$n-1,$$ $$(n-2)!=1+n+\cdots+n^{m-1}\tag{1}$$ Since $$n>5$$ is prime, $$n-1$$ is composite and $$(n-1)|(n-2)!$$ (Prove this.)

The preceding is Mindlack's hint, but I gather you haven't seen where to go from there.

Reducing both sides of $$(1)$$ modulo $$n-1$$ gives $$0\equiv m\pmod{n-1}.$$ Since $$n-1$$ divides $$m$$, we have $$m\ge n-1.$$

Now argue that $$n^{n-1}>1+(n-1)!$$

• Not getting how $1+n+\cdots +n^{m-1}\equiv m\pmod{n-1}$! Probably missing something trivial.. Mar 29, 2019 at 16:40
• @tarit There are $m$ terms, each of which is congruent to $1$ mod $n-1$ Mar 29, 2019 at 16:43
• Oops. Nice solution, can you share how you think what is necessary while solving a particular problem?,e.g; this one Mar 29, 2019 at 16:52
• @taritgoswami I wish I could. Actually, this problem appears in Tom Apostol's undergraduate Analytic Number Theory book. Many years ago, somebody showed me how to do it after I failed to solve it by myself. I was sure I'd found all the solutions, and that the exponent would be too big for there to be others. I think the key technique is to realize that you have to start by assuming $n$ is somewhat large, since we know there are some solutions. Examine closely how the argument uses $n>5.$ Mar 29, 2019 at 17:01
• Thanks for sharing :) Mar 29, 2019 at 17:41