An algebraic characterization of connected sum factors of closed 3-manifolds