Congruence of $29^p \pmod p$

46 Views Asked by At

For how many primes p we have: $p \mid 29^p+1$

My attempt: $p \mid 29^p+1 \rightarrow 29^p\equiv -1\pmod p \rightarrow (29^p)^2\equiv (-1)^2\pmod p$ Which gives us: $$29^{2p}\equiv 1\pmod p $$That is true iff:$$\phi(p)\mid2p \rightarrow p-1\mid2p$$Since $p-1|p$ only for $p=2$, for $p>2$ we have $p-1\mid2$ i.e. $p=3$, thus this leads to: $p=2,3$ as only solutions.

I checked the solution to the problem, turns out $p=5$ also works (so $p=2,3,5$ are all the solutions), checking for my arguement we would have $5-1\mid2\cdot5$ which is clearly incorrect... why is my arguement wrong?