It is almost a standard question, to start. Later it turns out to be difficult. Your approach should be to factorise the polynomial ….
p = 1 results in f(1) = 1 – 7 + 6 + 12, not equal to 0
p = –1 results in f(–1) = –1 – 7 – 6 + 12, not equal to 0.
p = 2 results in f(2) = 8 – 28 + 12 + 12, not equal to 0
p = 3 results in f(3) = 27 – 63 + 18 + 12, not equal to 0
p = 4 results in f(4) = 64 – 112 + 24 + 12, not equal to 0
We should realise that for no further positive natural values, will f(x) be equal to 0. If you dont know why, read further, the reason will be clear.
Now analysing the polarity(+ve or –ve) of f(x),
we see that f(–1) < 0
f(0) > 0. Thus, one root will lie between –1 & 0.
Further, f(1) > 0 and f(2) > 0. But f(3) < 0
Thus, another root will lie between 2 & 3.
f(4) < 0. But we are sure that as x increase, f(x) has to turn out to be positive (Why? Coefficient of p³ is positive)
f(5) = 125 – 175 + 30 + 12 < 0
f(6) = 216 – 252 + 36 + 12 > 0
Thus, the third and last root will lie between 5 & 6.
Now, you should have learned that when you plug values of x (in this case p), not only should you focus on whether the polynomial is 0, but also look at the transition of values from positive to negative or vice-versa.
And for p being any value 6 or more, the polynomial will ALWAYS be positive.
Thus, required value of q is 6.
https://www.desmos.com/calculator is an extremely good graphing tool. The graph of the above polynomial, as plotted on Desmos Graph, is as below. Use it to co-relate to what we have learnt.