The formula for magnesium oxide is MgO.
Magnesium oxide is an ionic compound formed between magnesium (Mg) and oxygen (O). Magnesium loses two electrons to become Mg2+, while oxygen gains two electrons to become O2-. These oppositely charged ions are then attracted to each other, forming the compound. Because the charges of the magnesium and oxygen ions are equal and opposite (+2 and -2, respectively), they combine in a 1:1 ratio, resulting in the formula MgO. The net charge of the compound is zero.