I came across the following question:
If the sum of two integers is 30, then their product maybe?
1. -5400
2. -1000
3. 200
4. 224.75
5. 250
So I solved it by the following method:
let two numbers be x and y
Hence "x + y = 30"
and x*y = assumed a
Quadratic equation will be "x*(30-x) = a". Further simplyfying to:
x^2 -30x + a = 0
So two roots will be:
(x, y) = (-(-30) ± sqrt(30^2 - 4*a)) / 2
I substituted values from options. Ultimately I found that options 1, 2 & 3 are correct. But I did this by trial and error (kind of).
Is there any way to find without substituting options?
P.S. I want to implement this in python. But I am struggling to solve it by hand.
Well, all you had to do was check the determinant of the quadratic equation. $$b^2\ge4ac$$ $$30^2\ge 4a$$ $$a\le 225$$ Hence for all products below $225$, there will be two numbers which satisfy the required conditions. This tells us that options $1,2,3,4$ are correct. However, two integers when multiplied do not give option $4$. Therefore, the answer is options $1,2$ and $3$.