Finding the least number to be added to an integer $N$ to make it a Perfect Square is simple: https://www.geeksforgeeks.org/least-number-to-be-added-to-or-subtracted-from-n-to-make-it-a-perfect-square/
But how do we proceed if we require the number to be added must be a fourth power divided by four $\frac{a^4}{4}$?
Assume $N=p_1\cdot p_2$ is a product of two primes. How do I find a number $a$ such that $\frac{a^4}{4}+N$ is a perfect square?
An example $N=p\cdot q=7\cdot3=21$ and we find $a=2$ which produces a perfect square $21+\frac{2^4}{4}=25$ too.
Another example $N=p\cdot q=7\cdot11=77$ and we find $a=2$ which produces a Perfect Square $77+\frac{2^4}{4}=81$.
An example including larger numbers is $N=p\cdot q=5\cdot13=65$ and we find $a=8$ which produces a perfect square $65+\frac{8^4}{4}=1089$.
For a given $N$, is there a way to find such an integer $a$ (without brute force)?
Given $n=pq$ with $p$ and $q$ prime and $p\leq q$, if $a$ is an integer such that $$n+\frac{a^4}{4}=c^2,$$ for some positive integer $c$, then $\tfrac{a^4}{4}$ is an integer and so $a$ is even, say $a=2b$. Then also $$pq=n=c^2-\tfrac{a^4}{4}=c^2-4b^4=(c-2b^2)(c+2b^2).$$ Then either $c-2b^2=1$ and $c+2b^2=pq$, or $c-2b^2=p$ and $c+2b^2=q$, and correspondingly $$(2b)^2=pq-1\qquad\text{ or }\qquad (2b)^2=q-p,$$ where of course $q-p$ is the smaller of the two. So