Calcium has an atomic number, Z, of 20, therefore the number of protons = 20
Calcium is uncharged neutral atom, therefore the number of electrons = number of protons = 20
Mass number, A, is 40
Number of neutrons = A- Z = 40-20 = 20
When calcium forms calcium ion, Ca2+, it loses 2 electrons. So, number of electrons decrease by 2 while protrons and neutrons remain the same.
For calcium ion,
Number of neutrons = number of protons = 20 and number of electrons = 18