I was reading a question in one of the previous pages, in searching for a proof I stumble across what seem like a contradiction. All I want is for someone to provide the missing link in my argument.
The question
Find the least $n$ for which $38^n+31$ is prime.
My attempt at a proof
If $38^n+31$ composite, then there exist at least a prime $p$ such that $p|38^n+31$. Now $\gcd(p,38)=1$, otherwise, $d=\gcd(p,38)=2$ or $19$ and $d|31$ a contradiction. Hence, by Fermat's Little Theorem; $38^{p-1} \equiv 1 \pmod p$, and for all positive integer $r$, $38^{r(p-1)} \equiv 1 \pmod p$.
Hence, $38^{r(p-1)}+31 \equiv 32 \pmod p$, but $38^{r(p-1)}+31 \equiv 0 \pmod p$, because it's composite. It follows that $32 \equiv 0 \pmod p$ i.e $p|32$, a contradiction, and hence, the above expression cannot be composite (but inputing real values for $n$ shows that it is indeed composite).