# To find all $n$ such that $(n-1)!+1$ is a perfect power of $n$

How to find all positive integers $$n$$ such that $$(n-1)!+1$$ can be written as $$n^k$$ for some positive integer $$k$$?

• If $n>4$ composite then $n|(n-1)!$ that implies $\gcd((n-1)!+1,n^k)=1$, so $n$ must be a prime. I guess it is related with Wilson's theorem May 22, 2014 at 8:00
• Wilson's theorem is also what pops out in my head when I see this question. May 22, 2014 at 8:21
• Aug 29, 2017 at 19:48

For $$n=2,3,5$$ the number $$(n-1)!+1$$ is a perfect power of $$n$$, but not for $$n=1$$ or $$n=4$$.
Let $$n>5$$ be such that $$(n-1)!+1$$ is a perfect power of $$n$$. If $$n$$ is composite then $$(n-1)!$$ is divisible by $$n$$, so $$(n-1)!+1$$ cannot be a perfect power of $$n$$, so $$n$$ must be prime.
Let $$p>5$$ be a prime and suppose there exists $$k\in\Bbb{Z}$$ such that $$(p-1)!+1=p^k$$. Then $$(p-1)!=p^k-1=(p-1)\cdot\sum_{i=0}^{k-1}p^i,$$ which shows that $$(p-2)!=\sum_{i=0}^{k-1}p^i$$. We have $$(p-2)!\equiv\sum_{i=0}^{k-1}p^i\equiv k\pmod{p-1},$$ and because $$p-1>4$$ is composite we have $$k\equiv(p-2)!\equiv0\pmod{p-1}$$. The inequalities $$p^k-1=(p-1)!<(p-1)^{p-1} of integers show that $$k, and clearly $$k>0$$, a contradiction.
Therefore $$n=2,3,5$$ are the only positive integers such that $$(n-1)!+1=n^k$$ for some $$k\in\Bbb{Z}$$.
• What is the use of $k'$. It seems you can get $0\equiv k\pmod{p-1}$ directly from $(p-2)!=\sum_{i=0}^{k-1}p^i$. May 22, 2018 at 12:27
• In addition, it seems $(p-1)^{p-1}<p^{p-1}$ is needless. $k<p-1$ can be derived from $p^k-1<(p-1)^{p-1}$, but cannot from $p^k-1<p^{p-1}$. May 22, 2018 at 12:48