Primary Ideal in a PID 
Let $R$ be a PID. An ideal $P$ in $R$ is said to be primary if $ab \in P$ and $a \notin P$ implies $b^n \in P$ for some $n \in \Bbb{N}$. Show that $P$ is primary if and only if $P = (p^n)$ for some $n \in \Bbb{N}$ and some prime element $p \in P$.

Here is my attempt:

Assume that $P = (p^n)$, and suppose that $ab \in P$ but $a \notin P$. Then $p^n|ab$ and therefore $p|ab$. Since $p$ is prime, either $p|a$ or $p|b$. The former is contrary to our assumption, so $p|b$ and therefore $p^n |b^n$ which implies $b^n \in (p^n) =P$
Now for other direction. Assume that $P$ is a nontrivial primary ideal. Since $R$ is a PID, $P=(x)$ for some nonzero $x \in R$ non-unit. Since $P$ is also a UFD, $x=p_1^{a_1} ... p_n^{a_n}$ for some prime/irreducible elements $p_i$ and $a_n \in \Bbb{N}$. Let $a = p_1^{a_1}$ and $b = p_2^{a_2} ... p_n^{a_n}$. Then, since $P$ is primary, $a \in P$ or $b^k \in P$ for some $k \in \Bbb{N}$. If $a \in P = (x)$, then $x \mid a = p_1^{a_1}$; and since $p_1^{a_n} \mid (p_1^{a_1}...p_n^{a_n})=x$, we get $P=(x) = (p_1^{a_n})$.

Here is where I get stuck. I am not sure how to deal with the $b^k \in P$ case. If $b^k \in P = (x)$ holds, then $x \mid b^k = p_2^{ka_2} ... p_n^{ka_n}$ and therefore $p_1^{a_1} \mid p_2^{ka_2} ... p_n^{ka_n}$ and therefore $(p_2^{ka_2} ... p_n^{ka_n}) \subseteq (p_1^{a_1})$...Doesn't seem helpful...We do have $(p_1^{a_1}) \subseteq (x)$. But we also have $x= p_1^{a_1} p_2^{a_2} ... p_n^{a_n} = \ell p_1^{a_1}$ or $x \in (p_1^{a_1})$, which would prove $(x) = (p_1^{a_1})$. This doesn't seem right, however, because (1) I didn't use $b^k \in (x)$ anywhere, and (2) it would also be the case that $(x) = (p_1^{a_1})$, which doesn't seem right. I must be making some fundamental error somewhere.
 A: For simplicity, I write my idea in the case of $k=3$. This will leads a contradiction unless $k=1$ or $P=0$. The idea can be applied to any other $k$.
$x=p_1^{a_1}p_2^{a_2}p_3^{a_3}$ where $p_1,p_2,p_3$ $(k=3)$ are non-associated irreducible elements, and $P=(x)$, $a=p_1^{a_1}$, $b=p_2^{a_2}p_3^{a_3}$
. And $a_1,a_2,a_3\ge1$
If there is some $n\ge 1$ to make $(p_2^{a_2}p_3^{a_3})^n=p_2^{na_2}p_3^{na_3}\in P$, then $p_1^{a_1}p_2^{a_2}p_3^{a_3}$ | $p_2^{na_2}p_3^{na_3}$. Since $R$ is integral domain, $p_1^{a_1}$ | $p_2^{(n-1)a_2}p_3^{(n-1)a_3}$. And since $R$ is UFD, $p_1$ is prime element, and thus $p_1|p_2^{(n-1)a_2}$ or $p_1|p_3^{(n-1)a_3}$, say $p_1|p_2^{(n-1)a_2}$ (if $n=1$, then $p_1$ is unit, so we assume $n\ge 2$). Then $p_1|p_2$, $p_1y=p_2$ and thus $y$ is unit, so $p_1$ associates with $p_2$. 
This is contradiction unless $k=1$ or $P=0$.
A: Let $R$ be a PID and $P$ be an ideal in $R$.  Since $R$ is a PID we have that $P = (x)$ for some $x \in R$.  It will be helpful to recall that every PID is a UFD, so $R$ is a UFD.  
Assume that $P$ is primary.  Since $R$ is a UFD, $x$ can be written as a product of a unit and prime elements of $R$.  We wish to show that $x = p^n$ for some prime element $p$ of $R$, and $n \in \mathbb{N}$.  Suppose, to the contrary, that can be written as $x = ab$ where $a$, $b$ are not units, and there exist prime elements $p_1, p_2$ such that $p_1 | a$ and $p_2 | b$, but $p_1 \nmid a$ and $p_2 \nmid b$.  Then $ab \in P$, and since $P$ is primary, either $a \in P$ or $b^n \in P$ for some $n \in \mathbb{N}$.  Notice that every element of $p' \in P$ is of the form $p' = kx = k(ab)$, for some $k \in R$.  Thus, $a | p'$ and $b | p'$ for all $p' \in P$.  Since $p_2 | b$, but $p_2 \nmid a$, we have that $b \nmid a$, so $a \notin P$. Since $p_1 | a$, but $p_1 \nmid b$, $a \nmid b^n$ for all $n \in \mathbb{N}$, and $b^n \notin P$ for all $n$.  This gives our desired contradiction, so $x$ is a power of some prime element in $R$.
To show the converse, assume that $x = p^n$ for some prime element $p \in R$ and $n \in \mathbb{N}$, and let $ab \in P$.  Then $p^n | ab$, so $p | ab$ and $p | a$ or $p | b$.  We will show that if $b^k \notin P$ for all $k \in \mathbb{N}$, then $a \in P$, and thus that $P$ is a primary ideal.  Suppose $b^k \notin P$ for all $k \notin \mathbb{N}$.  Then $p^n \nmid b^k$ for all $k\in\mathbb{N}$, so $p \nmid b$ (To see this step consider that $p | b$ implies $p^n | b^n$).  Since $p \nmid b$ and $p^n | ab$, it follows that $p^n | a$, so $a \in P$.  Thus, $P$ is a primary ideal.
A: Here's a different approach.  Given a nonzero primary ideal $Q = (a)$, then $P := \sqrt{Q}$ is a prime ideal and $Q \subseteq P$.  Since $R$ is a PID, then $P = (p)$ for some prime element $p$.  By the definition of the radical, then $p^m \in Q$ for some $m$, so $a \mid p^m$.  This shows that, up to associates, $p$ is the only prime that can appear in the factorization of $a$.  Indeed, if $q$ is prime and $q \mid a$, then $q \mid p^m$ so $q \mid p$.  Since primes are irreducible, then $q$ and $p$ must be associate.  Thus $a = u p^k$ for some $k \in \mathbb{Z}_{\geq 0}$ and some $u \in R^\times$, so
$$
Q = (a) = (u p^k) = (p^k) \, .
$$
