# Find all positive integers $n$ for which $(n-1)!+1$ is a power of $n$

As the title says,

Find all positive integers $n$ for which $(n-1)!+1$ is a power of $n$.

The solutions I've found are $\{2,3,5\}$ (thanks Brandon!), but I'm having difficulties proving that these are the only ones. What I've got so far is that $n$ must be prime since $(n-1)!+1$ would not be congruent to $n$ if $n$ were composite.

-
$n=2,3$ are solutions as well. – Brandon Carter Dec 18 '11 at 7:12
@Carlos: People like to see their answers are accepted by the OP. – Ehsan M. Kermani Dec 25 '11 at 4:56

Well, for primes $p < 1290,$ those for which $$1 + (p-1)! \equiv 0 \pmod{p^2}$$ are the three $$\{ 5, \; \; 13, \; \; 563 \}$$

As soon as $p \geq 7,$ we have $(p-1)! > p^3,$ so we need $1 + (p-1)! \equiv 0 \pmod{p^3},$ and, in fact, $1 + (p-1)! \equiv 0 \pmod{p^4}.$ Quite rare.

-
On the other hand, $(13-1)!+1=13^2 \times 2834329$ – J. M. Dec 18 '11 at 9:20
@J.M. yes, I factored these for $p \leq 61$ in gp-Pari, I don't see any chance for more solutions, which is what the large unpredictable prime factor with $p=13$ tells me. I know $v_{563} (1 + 562!) \geq 2$ but not the exact value. – Will Jagy Dec 18 '11 at 9:29

This is really an old problem in ML. Note that, the equation doesn't hold for primes $>5$ which is in fact the Liouvilles'theorem

-
What does "ML" mean? If it is not a standard or common abbreviation (and it appears so to me), then it may be better to write it out in full. – Srivatsan Dec 25 '11 at 9:03
It's pretty famous though! MathLinks. – Ehsan M. Kermani Dec 25 '11 at 10:44