Let $f(x) = a_0+a_1x+\cdots+a_nx^n$ be a polynomial of degree $n$ over $\Bbb Z$.
A: If a rational number $\frac{p}{q}$ is a root of $f(X)$, show that $p\mid a_0$ and $q\mid a_n$. Assume $\gcd(p, q) = 1$. We've discussed in class how to proof this if $f(X) = a_0\cdot a_1X\cdot a_nX^n$, but I'm not sure how to do this since each piece is added together instead. Would I go about this by factoring something out? Any help on how to think about this problem is helpful.
B: Use part A to find all rational roots of the following polynomials, and factor them into irreducible polynomials in $\Bbb Q[X]$: $$f(x) = 9x^3+18x^2-4x-8\tag{a}$$ $$g(x) = 6x^4-7x^3+8x^2-7x+2\tag{b}$$
I included part B, but am interested in solving A first (obviously).
Thank you
Suppose $p/q$ with $(p,q)=1$ is a root. Then $$ 0=f(p/q)=a_0+a_1(p/q)+\cdots+a_n(p/q)^n $$ Multiplying by $q^n$, we have $$ 0=a_0q^n+a_1pq^{n-1}+\cdots+a_{n-1}p^{n-1}q+a_np^n. $$ Note that $p|0$ and $p$ divides every term $a_jp^jq^{n-j}$ for $j\geq 1$ on the RHS above. It must be that $p|a_0q^n$. Since $(p,q)=1$, we infer that $p|a_0$. Similarly, $q|0$ and $q|a_jp^jq^{n-j}$ for all $j<n$. It must be that $q|a_np^n$, which together with $(p,q)=1$ once more, implies $q|a_n$.