答案:$7$
$\begin{array}{rcl}
P(\text{抽出紅球}) & = & \dfrac{\text{紅球的數目}}{\text{所有球的數目}} \\
\dfrac{2}{5} & = & \dfrac{8}{n + 5 + 8}\\
2n + 26 & = & 40\\
2n & = & 14 \\
n & = & 7
\end{array}$
$\begin{array}{rcl}
P(\text{抽出紅球}) & = & \dfrac{\text{紅球的數目}}{\text{所有球的數目}} \\
\dfrac{2}{5} & = & \dfrac{8}{n + 5 + 8}\\
2n + 26 & = & 40\\
2n & = & 14 \\
n & = & 7
\end{array}$