Number of Solutions for $p^2 - q^2$ = n?

3k Views Asked by At

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 ?

2

There are 2 best solutions below

9
On BEST 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.

0
On

Write the given equation as $p^2-q^2=388$.

Now prime factorize R.H.S. Click this to view the entire solution.