<s>[INST] 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? 
 [/INST] 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.
</s>