<s>[INST] Where did I go wrong in applying the factor theorem? 
Given that $x + 1$ and $x - 3$ are two of the four factors of the expression $x^4 + px^3 + 5x^2 + 5x + q$, find the values of $p$ and $q$.

I tried to answer this question using the factor theorem but got the answer wrong:
$$ \text{Let } f(x) = x^4 + px^3 + 5x^2 + 5x + q $$
$$ \text{Since } x + 1 \text{ and } x - 3 \text{ are factors of } f(x), \text{ then } f(-1) = 0 \text{ and } f(3) = 0, \text{ i.e.} $$
\begin{align}
(-1)^4 + p(-1)^3 + 5(-1)^2 + 5(-1) + q &= 0 \color{red}{\leftarrow (1)} \\
(3)^4 + p(3)^3 + 5(3)^2 + 5(3) + q &= 0 \color{blue}{\leftarrow (2)}
\end{align}
$$ \text{From } \color{red}{(1)}: $$
\begin{align}
(-1)^4 + p(-1)^3 + 5(-1)^2 + 5(-1) + q &= 0 \\
1 + p(-1) + 5(1) + (-5) + q &= 0 \\
1 - p + 5 - 5 + q &= 0 \\
1 - p + q &= 0 \\
q &= p - 1 \color{limegreen}{\leftarrow (3)}
\end{align}
$$ \text{From } \color{blue}{(2)}: $$
\begin{align}
(3)^4 + p(3)^3 + 5(3)^2 + 5(3) + q &= 0 \\
81 + 27p + 45 + 15 + q &= 0 \\
27p + q + 60 + 81 &= 0 \\
27p + q + 141 &= 0 \\
q &= -27p - 144 \color{orange}{\leftarrow (4)}
\end{align}
$$ \color{orange}{(4)} + \color{limegreen}{(3)}: $$
\begin{align}
-27p - 144 &= p - 1 \\
-27p - p &= 144 - 1 \\
-28p &= 143 \\
28p &= -143 \\
p &= -\frac{143}{28} \\
\therefore p &= -5\frac{3}{28} \color{mediumpurple}{\leftarrow (5)}
\end{align}
$$ \text{Substitute } \color{mediumpurple}{(5)} \text{ into } \color{limegreen}{(3)}: $$
\begin{align}
q &= -5\frac{3}{28} - 1 \\
\therefore q &= -6\frac{3}{28}
\end{align}
The answers were $ p = -5, q = -6 $.
Where did I go wrong?
 [/INST] Just another way.
Consider
$$y=\frac{x^4 + px^3 + 5x^2 + 5x + q } {(x+1)(x-3) }$$ and perform the long division. You will have
$$y=-\frac{q}{3}+\left(\frac{2 q}{9}-\frac{5}{3}\right) x-\left(\frac{7
   q}{27}+\frac{5}{9}\right) x^2+\frac{1}{81} x^3 (-27 p+20 q-15)+\frac{1}{243}
   x^4 (54 p-61 q-96)+\cdots$$
So,
$$-27 p+20 q-15=0$$
$$54 p-61 q-96=0$$
Solve for $(p,q)$ (simple).
</s>