I am working on a problem that I need a simple method of identifying whether a positive integer $n$ can be expressed as
\begin{equation\*}
n=4p^2q^2-(p+q)^2
\end{equation\*}
or
\begin{equation\*}
n=4p^2q^2-(p-q)^2
\end{equation\*}
in which $p,q$ are positive integers. Do integers of these forms have any special characters?


One obvious thing is that $n\equiv 0,3 \mod 4$ to qualify either of them. Anything more than that?



Characters of integers of $4p^2q^2-(p\pm q)^2$ form
It can be seen that both forms can be factored as differences of squares.
Correspondingly, $n$ can be expressed in these forms iff there exists a divisor $d\mid n$ such that $d$ and $\frac{n}{d}$ have the same parity, and
$$(\star)\qquad \left(\frac{n}{d}-d\right)^2 \mp 4\left(\frac{n}{d}+d\right)$$
is a square (where the "$-$" sign corresponds to the former form, while the "$+$" sign corresponds to the latter one). 


To test this condition, one can iterate $d$ over the divisors of $n$ if $n$ is odd, and over the twice the divisors of $\frac{n}{4}$ if $n$ is a multiple of 4, and check if $(\star)$ is a square.


