To achieve a stable electron configuration, phosphorus needs to gain three electrons. This is because phosphorus belongs to Group 15 of the periodic table, also known as the nitrogen family. Elements in this group have five valence electrons, and they tend to gain three more electrons to complete their outermost energy level, achieving a stable configuration similar to that of a noble gas.