This is an exercise from Spivak's "Calculus" 4th edition.
18.a. Prove that if $x$ satisfies $$x^n + a_{n-1}x^{n-1}+ \dots + a_0 = 0$$ for some integers $a_{n-1}, \dots, a_0$, then $x$ is irrational unless $x$ is an integer.
The solution is given as
Suppose $x = p/q$ where $p$ and $q$ are natural numbers with no common factor. Then $$\frac{p^n}{q^n} + a_{n-1}\frac{p^{n-1}}{q^{n-1}}+ \dots + a_0 = 0$$, so $$\tag{*} p^n + a_{n-1}p^{n-1}q + \dots + a_0 q^n = 0$$ Now if $q \neq \pm 1$, then $q$ has some prime number as a factor. This prime factor divides every term of (*) other than $p^n$, so it must divide $p^n$ also. Therefore it divides $p$, a contradiction. So $q = \pm 1$, which means that $x$ is an integer.
I am confused about the conclusions in bold above. How does every other term of (*) being divisible by the prime factor affect $p^n$? Also, I've been struggling to prove that if $k$ is prime and $k|p^n$, then $k|p$, which seems to be the lemma used above.