Find all prime numbers p such that both numbers $4p^2+1$ and $6p^2+1$ are prime numbers? I tried $p$ for $2, 3$ and $5$ and they are not primes for both cases. How can I find all these prime numbers that satisfy those conditions? 
 A: Only $p = 5$ satisfies both $4p^2 + 1$ and $6p^2 + 1$ being prime, giving the primes $101$ and $151$.
For other odd primes either $4p^2 + 1$ or $6p^2 + 1$ can be prime, but not both. Given an odd prime $p \neq 5$, we have $p^2 \equiv 1$ or $9 \bmod 10$. The former gives $4p^2 + 1 \equiv 5 \bmod 10$ which is clearly composite on account of being divisible by $5$, while the latter gives $6p^2 + 1 \equiv 5 \bmod 10$, also a multiple of $5$.
A: You might want to double-check your numbers: $4 \times 5^2 + 1 = 4 \times 25 + 1 = 101$, which is prime, and $6 \times 5^2 + 1 = 6 \times 25 + 1 = 151$, which is also prime.
But you're right about $2$ and $3$: $4 \times 2^2 + 1 = 17$, which is prime, but $6 \times 2^2 + 1 = 25$ which is obviously composite; and $4 \times 3^2 + 1 = 37$, which is prime, but $6 \times 3^2 + 1 = 55$, which is also composite.
Maybe if $p \neq 5$ then either $5 \mid (4p^2 + 1)$ or $5 \mid (6p^2 + 1)$? Well, if $p$ is a prime other than $5$, then $p \equiv 2, 3 \textrm{ or } 4 \pmod 5$. If $p \equiv 4 \pmod 5$ then $p^2 \equiv 1 \pmod 5$ and $4p^2 + 1 \equiv 0 \pmod 5$. But if $p \equiv 2 \textrm{ or } 3 \pmod 5$, then $p^2 \equiv 4 \pmod 5$ and $6p^2 + 1 \equiv 0 \pmod 5$.
Ergo, no other prime can satisfy both conditions.
A: If $\ p\neq 5\ $ then $\  {\rm mod}\ 5\!:\,\ p\not\equiv 0\,\Rightarrow\, p\,\equiv\, \color{#c00}{\pm1}\,\ {\rm or}\ \color{#0a0}{\pm 2}\ \Rightarrow\ \Bigg\lbrace 
\begin{align} {p^2\equiv \color{#c00}1} &\Rightarrow\,4p^2\!+\!1\equiv\ 5\ \equiv 0 \\ 
  {{\rm or}\ \ p^2\equiv \color{#0a0}4} &\Rightarrow\,6p^2\!+\!1\equiv 25\equiv 0\end{align}$
Remark $ $ So it boils down to $\bmod 5\!:\ p\not\equiv 0\,\Rightarrow\, p^2\equiv \pm1,\,$ a special case of Euler's Criterion.
