This is taken from page 226 in Essential Astrophysics by Lang:
"The mass defect, ##ΔM##, for a nucleus containing ##A## nucleons, ##Z## protons, and ##A-Z## neutrons is
$$ΔM = Z m_p + (A - Z) m_n - m_{nuc}$$ where ##A## is the mass number of the nucleus, ##Z## is the atomic number, ##m_p## is...