Factor the expression by grouping. First, the expression needs to be rewritten as $x^{2}+ax+bx+18$. To find $a$ and $b$, set up a system to be solved.
$$a+b=-9$$ $$ab=1\times 18=18$$
Since $ab$ is positive, $a$ and $b$ have the same sign. Since $a+b$ is negative, $a$ and $b$ are both negative. List all such integer pairs that give product $18$.
$$-1,-18$$ $$-2,-9$$ $$-3,-6$$
Calculate the sum for each pair.
$$-1-18=-19$$ $$-2-9=-11$$ $$-3-6=-9$$
The solution is the pair that gives sum $-9$.
$$a=-6$$ $$b=-3$$
Rewrite $x^{2}-9x+18$ as $\left(x^{2}-6x\right)+\left(-3x+18\right)$.
$$\left(x^{2}-6x\right)+\left(-3x+18\right)$$
Factor out $x$ in the first and $-3$ in the second group.
$$x\left(x-6\right)-3\left(x-6\right)$$
Factor out common term $x-6$ by using distributive property.