# $p=n^2-18n+77$: If $p>0$ and $p$ is prime, find $p$

I am working on my scholarship practice exam which assumes high school or pre-university math knowledge and stuck at this question. Could you please have a look?

Let $$p=n^2-18n+77$$ for a natural number $$n$$. If $$p>0$$ and $$p$$ is prime, then $$p=.....$$

I started by factorizing the equation to $$(n-7)(n-11)$$ and drew the graph below.

I am not sure how to continue here. It seems that when $$p>0$$ or above $$x$$-axis, $$p$$ can be many values which are prime, seeing from the graph.

The answer provided is $$5$$. Please advise.

• Remember your definitions and what it means for a number to be prime. – JMoravitz Jun 17 at 13:46

Hint: You know $$p=(n-7)(n-11)$$, so if $$p$$ is prime the two factors $$n-7,n-11$$ must be $$1,p$$ or $$-1,-p$$ in some order.
• Yes, I got it now. By applying the definition of prime number that briefly is the natural number that can be formed by multiplying only $1$ and itself, one of the terms would therefore equal $1$ and another would equal $p$ and check if $p$ is prime. Otherwise, swap the order and try again. Thank you for your hint. And apologies the question might be too amateur. I am not majoring in maths and trying my best to self study it. Thank you again, it helps a lot :) – Trey Anupong Jun 17 at 13:59