Find $p$ and $q$ such that $x^2+px+q<x$ iff $x \in (1,5)$

So $1$ and $5$ are the roots of $x^2+px + q = x$:

$$\begin{align*} (x-1)(x-5) &= 0\\ x^2 - 6x + 5 &= 0\\ x^2 - 5x + 5 &= x\\ p &= -5\\ q&= 5 \end{align*}$$


First rearrange as follows: $$x^2+px+q<x\iff x^2+(p-1)x+q<0$$ Recall from the properties of parabolas that $$ax^2+bx+c<0$$ between the (real) roots of the equation if $a>0$. So since in our case $a=1>0$, the parabola $$x^2+(p-1)x+q<0$$ between its zeros. So since we are given that $x\in(1,5)$ is the solution set, we surmise from above that $x^2+(p-1)x+q=(x-1)(x-5)=x^2-6x+5\implies p=-5$ and $q=5$