On a factorization of the Schrödinger and Klein–Gordon operators