Solution (source code)

= Solution

Choose $f=1$, so that $R_f=R$ and $f\notin\mathfrak p$. For an <integral domain>, the canonical <ring homomorphism> $R\to R_{\mathfrak p}$ is <injective>: if $a/1=0$, the <vanishing criterion in a module localization> gives $sa=0$ for some $s\notin\mathfrak p$. Such an $s$ is nonzero, so the absence of <zero divisors> gives $a=0$. Thus
$$
\boxed{f=1\text{ works whenever }R\text{ is an integral domain}.}
$$