Find all $p \in \mathbb{Z}$ such that $ p^2+ 4p + 16 $ is a perfect square I've tried some things involving modular residues but they don't seem to work. Anyone know how to do this? 
 A: So, we need $(p+2)^2+12=m^2$ for some integer $m$
$-12=(p+2-m)(p+2+m)$
As $p+2-m+p+2+m$ is even, the multiplicands have the same parity $\implies $ both must be ven
Consequently, $$\dfrac{p+2-m}2\cdot\dfrac{p+2+m}2=-3=1(-3)=(-1)3$$

Alternatively let $p^2+4p+16=(p+a)^2$ for some integer $a$
$\implies p=\dfrac{a^2-16}{4-2a}$
$\iff-2p=\dfrac{a^2-16}{a-2}=a+2-\dfrac{12}{2-a}$
$\iff12=(2-a)(a+2+2p)$
As $a+2+2p+2-a$ is even, $a+2+2p,2-a$ must have the same parity which must even as $12$ is even
$\implies\dfrac{2-a}2\cdot\dfrac{2+a+2p}2=3=(-3)(-1)=3\cdot1$
A: The first thing you want to do is recognise that the expression is equivalent to $(p+2)^2+12$, which we require to be another perfect square. What this means is that we need two perfect squares which are exactly $12$ apart. Note that the distance between consecutive perfect squares increases as the numbers get larger: $(n+1)^2-n^2=2n+1$ is increasing. Furthermore, distance between non-consecutive perfect squares are even larger than that $(n+k)^2-n^2=2kn+k^2$. But the distance between the perfect squares that we are seeking for is only $12$, a pretty small number: that means the numbers we need to check are very small as well, and in particular, finite. If the numbers get too big, the difference between their squares is surely greater than $12$! Try to see if you can get somewhere with this observation.
A: So $p^2 + 4p + 16 = m^2$
$p^2 + 4p + 4 =m^2 - 12$
$(p+2)^2 = m^2 - 12$
$m^2 - (p+2)^2 = 12$
$(m + p + 2)(m - p - 2) = 12$
So $m+p+2 = k$ and $m-p-2 = j$ for two integers so that $kj = 12$.
Also note, $k + j = 2m$.
So $k + j$ is even.  So $\{k,j\} = \{\pm 2, \pm 6\}$ and .... thats it.  All other factors involve an odd number and an even number and will have an odd sum.
So $2m = \pm2 \pm 6 =8$ and $m =\pm 4$ and $p^2 +4p + 16 = 16$ so $p(p+4) = 0$ so $p= 0$ or $p = -4$.
===
Another alternative.  Note that $(n+1)^2 - n^2 = n^2 +2n +1 - n^2  =2n+1$ so that means $n^2 = (n-1)^2 + (2n-1)= (n-2)^2 + (2n-1) + (2n-3) = ...... = (n-n)^2 + (2n-1) + (2n-3) + ..... + 3 + 1= 1 + 3 + 5 + ..... + 2n-1$.
In other words $n^2 = $ the sum of the first $n$ odd numbers.
So if $p^2 + 4p + 16 = m^2$ then $(p-2)^2 - m^2 = 12$.  But $(p-2)^2$ is the sum of the first $p-2$ odd numbers.  And $m^2$ is the sum of the first $m$ odd numbers.  So $(p-2)^2 - m^2$ is the sum of the $m + 1$st odd number to the $p-2$ odd number.
In other words:  $12$ is a sum of a sequence of consecutive odd numbers.
The first such way of doing that is $5 + 7 = 12$.  The next such way would need $4$ terms averaging $3$ but the lowest  possible value is $1$ and $1 + 3+5 + 7$ is too big.
So $5 +7 = 12$ is the only option.  So $(p-2)^2 = 1+3=4$ and $m^2 = 1+3 + 5+7 = 16$ and $(p-2)^2 - m^2 = 12$ and so $p-2 = \pm 2$ and $m =\pm 4$.
So $p =0$ or $4$ are the only solutions.
