On a functional equation related to derivations in prime rings