Factor the expression by grouping. First, the expression needs to be rewritten as $x^{2}+ax+bx-24$. To find $a$ and $b$, set up a system to be solved.
$$a+b=-5$$ $$ab=1\left(-24\right)=-24$$
Since $ab$ is negative, $a$ and $b$ have the opposite signs. Since $a+b$ is negative, the negative number has greater absolute value than the positive. List all such integer pairs that give product $-24$.
$$1,-24$$ $$2,-12$$ $$3,-8$$ $$4,-6$$
Calculate the sum for each pair.
$$1-24=-23$$ $$2-12=-10$$ $$3-8=-5$$ $$4-6=-2$$
The solution is the pair that gives sum $-5$.
$$a=-8$$ $$b=3$$
Rewrite $x^{2}-5x-24$ as $\left(x^{2}-8x\right)+\left(3x-24\right)$.
$$\left(x^{2}-8x\right)+\left(3x-24\right)$$
Factor out $x$ in the first and $3$ in the second group.
$$x\left(x-8\right)+3\left(x-8\right)$$
Factor out common term $x-8$ by using distributive property.