Let [Formula: see text] be factorial domains containing [Formula: see text]. In this paper, we give a criterion, in terms of locally nilpotent derivations, for [Formula: see text] to be [Formula: see text]-isomorphic to [Formula: see text], where [Formula: see text] is nonzero and [Formula: see text]. As a consequence, we retrieve a recent result due to Masuda [Families of hypersurfaces with noncancellation property, Proc. Amer. Math. Soc. 145(4) (2017) 1439–1452] characterizing Danielewski hypersurfaces whose coordinate ring is factorial. We also apply our criterion to the study of triangularizable locally nilpotent [Formula: see text]-derivations of the polynomial ring in two variables over [Formula: see text].