[proofplan]
We show that no element of $\operatorname{Frac}(A) \setminus A$ can be integral over $A$. Given $x = a/b$ in reduced form (meaning some prime factor of $b$ does not divide $a$), we suppose $x$ satisfies a monic polynomial over $A$, clear denominators, and use primality in the UFD to derive a contradiction: the prime divides $a^n$ hence divides $a$, contradicting the choice of reduced form.
[/proofplan]
[step:Reduce to showing no element of $\operatorname{Frac}(A) \setminus A$ is integral over $A$]
Let $A$ be a UFD with fraction field $K = \operatorname{Frac}(A)$. By definition, $A$ is integrally closed if every element of $K$ that is integral over $A$ already lies in $A$. We prove the contrapositive: if $x \in K \setminus A$, then $x$ is not integral over $A$.
[/step]
[step:Write $x = a/b$ in a form where some prime factor of $b$ does not divide $a$]
Take $x \in K \setminus A$ and write $x = a/b$ with $a, b \in A$ and $b \neq 0$. Since $x \notin A$, the element $b$ is not a unit in $A$. Because $A$ is a UFD, $b$ has a factorisation into primes. Let $p \in A$ be a prime element dividing $b$. If $p \mid a$, write $a = pa'$ and $b = pb'$; then $x = a'/b'$. Repeat, extracting factors of $p$ from both numerator and denominator. Since $A$ is a UFD, the number of times $p$ divides $a$ is finite (namely, the $p$-adic valuation of $a$), so after finitely many steps we arrive at a representation $x = a/b$ with $p \mid b$ but $p \nmid a$.
[guided]
Why can we always arrange $p \mid b$ but $p \nmid a$? In a UFD, every nonzero non-unit element has a well-defined prime factorisation (up to units and reordering). The $p$-adic valuation $v_p(a)$ counts the number of times $p$ appears in the factorisation of $a$. Starting from any representation $x = a/b$, we have $v_p(a) < v_p(b)$ for at least one prime $p$ dividing $b$ (otherwise we could cancel all prime factors of $b$ from $a$, yielding $x \in A$). After cancelling the common factor $p^{\min(v_p(a), v_p(b))}$, we obtain $x = a'/b'$ with $v_p(a') = 0$ (i.e., $p \nmid a'$) and $v_p(b') \geq 1$ (i.e., $p \mid b'$). This is the representation we use.
[/guided]
[/step]
[step:Suppose $x$ is integral over $A$ and clear denominators]
Suppose for contradiction that $x$ is integral over $A$. Then there exist $n \geq 1$ and $a_1, \ldots, a_n \in A$ such that
\begin{align*}
\left(\frac{a}{b}\right)^n + a_1 \left(\frac{a}{b}\right)^{n-1} + \cdots + a_n = 0.
\end{align*}
Multiplying both sides by $b^n$ (which is nonzero in the integral domain $A$) gives
\begin{align*}
a^n + a_1 a^{n-1} b + a_2 a^{n-2} b^2 + \cdots + a_n b^n = 0.
\end{align*}
Rearranging:
\begin{align*}
a^n = -b\bigl(a_1 a^{n-1} + a_2 a^{n-2} b + \cdots + a_n b^{n-1}\bigr).
\end{align*}
[/step]
[step:Derive a contradiction using primality of $p$]
From the equation $a^n = -b(a_1 a^{n-1} + a_2 a^{n-2} b + \cdots + a_n b^{n-1})$, the right-hand side is divisible by $b$, and in particular by $p$ (since $p \mid b$). Therefore $p \mid a^n$.
Since $p$ is a prime element in the UFD $A$, the ideal $(p)$ is a prime ideal. Hence $p \mid a^n$ implies $p \mid a$: indeed, if $p \nmid a$, then $a \notin (p)$, and since $(p)$ is prime and $a^n = a \cdot a^{n-1}$, we would need $a \in (p)$ or $a^{n-1} \in (p)$. By induction on $n$, this forces $p \mid a$.
But $p \mid a$ contradicts our choice of representation in which $p \nmid a$. Therefore $x$ is not integral over $A$, and since $x \in K \setminus A$ was arbitrary, $A$ is integrally closed.
[guided]
The key algebraic fact is that prime elements in a UFD generate prime ideals, and in a prime ideal, $p \mid a^n$ forces $p \mid a$. Let us verify this carefully by induction on $n$.
**Base case** ($n = 1$): $p \mid a^1$ is simply $p \mid a$, which is immediate.
**Inductive step**: Suppose the claim holds for $n - 1$. Given $p \mid a^n = a \cdot a^{n-1}$, since $(p)$ is a prime ideal, either $p \mid a$ or $p \mid a^{n-1}$. In the first case we are done. In the second case, the inductive hypothesis gives $p \mid a$.
So $p \mid a^n$ implies $p \mid a$. But we chose the representation $x = a/b$ precisely so that $p \nmid a$. This is a contradiction, so the assumption that $x$ is integral over $A$ must be false.
Since every $x \in K \setminus A$ fails to be integral over $A$, every integral element of $K$ over $A$ lies in $A$, and $A$ is integrally closed.
[/guided]
[/step]