We have a prime $p$ and an integer $k > 0$. When does the following equation stand?

$(p-1)! + 1 = p^k $

I have obviously tried for some little numbers, and in some cases, it stands:

For $ p=2$ and $k=1, 1 + 1 = 2$.

For $ p=3$ and $k=1, 2 +1 = 3.$

For $ p=5$ and $k=2, 24 + 1 = 25.$

Any ideas, how to prove, if there are more, and if yes, what are the solutions?

  • $\begingroup$ No, it was actually a bad suggestion, that's why I deleted it. You've already stated the $p$ is prime, and Wilson theorem implies that only prime numbers can be candidates here, so it brings no additional insights. $\endgroup$ Mar 18, 2015 at 11:45
  • $\begingroup$ Okay, thanks for helping though. :) $\endgroup$
    – Atvin
    Mar 18, 2015 at 11:45
  • $\begingroup$ Nice question -- I suspect it's too hard to answer in general. Note that $p$ always divides $(p-1)! + 1$ and that no prime less than $p$ divides it. However, the number of primes less than $(p-1)!+1$ grows quadratically in $\log(p)$ whereas the number of primes less than $p$ grows linearly in $\log(p)$, so heuristically I suspect this becomes rarer and rarer as $p$ grows. $\endgroup$
    – hunter
    Mar 18, 2015 at 11:48
  • $\begingroup$ But you can combine the fact implied by Wilson theorem, and the fact that "factorial plus $1$ being square" is still an open problem (see here), in order to conclude that your question most likely falls under the same category (i.e., an open problem). $\endgroup$ Mar 18, 2015 at 11:49
  • 2
    $\begingroup$ If this is a homework it means there should be some way to determine it, said that, it doesn't hold for any prime between 6 and 20 so it doesn't seems to have any easy prime clasification, I would try to prove that the answer is that it just holds for $p=2,3,5$ but seems hard. $\endgroup$ Mar 18, 2015 at 12:13

1 Answer 1


We show there cannot be any solutions for $p\gt 5$ $$(p-1)!+1 = p^k \implies (p-1)! = p^k-1 = (p-1)\sum\limits_{i=0}^{k-1}p^i$$

Cancel $p-1$ both sides and get $$(p-2)! = \sum\limits_{i=0}^{k-1}p^i$$

Notice that left hand side is divisible by $p-1$ for $p\gt 5$ $$\begin{align}0&\equiv \sum\limits_{i=0}^{k-1}p^i \pmod{p-1}\\0&\equiv \sum\limits_{i=0}^{k-1}1 \pmod{p-1}\\0&\equiv k \pmod{p-1}\\k&=t(p-1)\end{align}$$

So we need $k$ to be of form $t(p-1)$

$$(p-1)! + 1 = p^{t(p-1)}$$

Clearly this is impossible because $(p-1)! + 1 \lt p\cdot p\cdots (\text{p-1 times}) = p^{p-1}$

That proves there are no solutions for $p\gt 5$.

  • $\begingroup$ Very nice and simple, thanks! $\endgroup$
    – Atvin
    Mar 18, 2015 at 15:13
  • $\begingroup$ Can you spell out why the left hand side is divisible by p−1 for p>5 please? $\endgroup$
    – user2321
    Mar 24, 2015 at 22:46
  • $\begingroup$ n is composite by definition, and therefore its factors must be in (n-1)!? $\endgroup$
    – user2321
    Mar 24, 2015 at 22:57
  • $\begingroup$ The only interesting case is if n is the square of a prime p and p > 2, then 2p is divisible by p and 2p < n, so (n-1)! is divisible by p², which is n. $\endgroup$
    – user2321
    Mar 24, 2015 at 23:03
  • 1
    $\begingroup$ It should be mentioned that $t>0$ because it's given that $k>0$ or because $(p-1)!>0$. Also, clearly $t\in\mathbb Z$. $\endgroup$
    – user26486
    Aug 29, 2017 at 20:20

Not the answer you're looking for? Browse other questions tagged .