# An element lies in a prime ideal but not in its square

Let $$R$$ be a UFD. I'm trying to understand whether the following statements are equivalent:

1) $$r\in R$$ lies in some prime ideal $$P$$ but not in the ideal $$P^2$$.

2) $$r$$ is divisible by a prime element of $$R$$ but not by its square.

I think I can see why 2) implies 1). Suppose 2) holds, say $$r$$ is divisible by a prime element $$p$$ but not by $$p^2$$. Then $$r$$ lies in the ideal $$P=(p)$$, which is prime because $$p$$ is prime. Also $$r$$ does not lie in $$P^2$$, because otherwise it would be divisible by $$p^2$$. Is that right?

Suppose 1) holds. $$P$$ is an abstract prime ideal. Does it necessarily contain a prime element? If so, I would be able to conclude that $$r$$ is divisible by that prime element. (I think it must be finitely generated since $$R$$ is a UFD, do the generators have to be prime elements?) Does the condition $$r\notin P^2$$ imply that $$r$$ is not divisible by the square of that element?

Your reasoning that $$(2) \implies (1)$$ is correct.
It is not true that $$P$$ must be finitely generated. If every prime ideal of a ring is finitely generated, then in fact every ideal is finitely generated, i.e. the ring is Noetherian (this is sometimes called Cohen's theorem). In general, UFDs are not Noetherian. A classic example is $$K[x_1, x_2, x_3, \ldots]$$, the ring of polynomials in an infinite number of variables over a field.
In a UFD we can factor $$r$$ as $$r = \prod p_i^{n_i}$$ with the $$p_i$$ distinct primes.
Show from the definition of prime ideal that $$r \in P$$ prime implies $$p_i \in P$$ for some $$i$$. Remember, $$P$$ prime means that $$ab \in P \implies a\in P \text{ or } b\in P$$. (In general you've now shown that a prime ideal of a UFD always contains a prime element. In fact this behavior characterizes UFDs, and is sometimes called Kaplansky's theorem)
Finally, show from this and the assumption that $$r \notin P^2$$ that $$p_i \mid r$$ but $$p_i^2 \nmid r$$