I was recently asked a question in an interview & have been unable to crack it, after my own efforts have failed & Google not showing any results , I am posting it here so that anyone else may also try their hand on it .
Given the equation:
a (a + b) = c - 120
where a
,b
& c
are unequal prime numbers, find a
, b
& c
.
I know I must use some property of the prime numbers to reduce the problem to a simpler one, but I can't think of one. Any suggestions/solutions will be appreciated.
The best I could come up with is that :
- There may be multiple solutions to it. My first approach was a brute force search for 3 prime numbers that solved this equations. (I know , totally useless)
- The second approach was a refinement of the first, to modify the equation to
a (a + b) - 120 = c
. So now we reduce our brute force variables to just a & b & check if the LHS is prime no for the selecteda
&b
. (Ifc
were to be large, finding out whether the LHS is a prime would take away the advantage gained by reducing the variables from 3 to 2.)
So you see, I am not really going anywhere.