Atomic no. of Mg = 12, Electronic configuration is 2,8,2 which is expanded as : 1s2 2s2 2p6 3s2
Number of electron = Number of proton = 12
Atomic mass of magnesium = 24
Number of neutron = Atomic mass - Number of proton = 24 - 12 = 12
Its valency is 2
Regards