Number of Solutions for $p^2 - q^2 = n$? how do I find it? It was asked in aptitude test of a company , couldn't figure it out. What is the answer of it?
Edit:
once again i faced similar question for :$p^2 - q^2 = 388$
options : 1 , 2 , 3 , More than 3.
what is answer ?
$n = p^2 - q^2 = (p+q)(p-q)$ So every such decomposition gives you a factorization and vice versa.
However there is a gotcha. If only one of $p+q$ and $p-q$ is odd, then $p$ is not an integer. So it is the number of factors where the parity of the two factors is the same.
Given the prime factorization of $n$ it is not hard to figure out how many such factorizations exist.