# Very elementary question about valence electrons of ionic compound

In a university entrance question, I found this question:

What is the number of valence electrons of $\ce{Mg(OH)2}$? Answer = 24

I know that Mg has 2 valence electrons and O has 6. But I don't know what I must do for a complete ionic compound. If I add them up I get 2+6+6+1+1 = 16, but the answer of this question was 24. Is the answer right? If yes, then how to get it?

• Your answer (16) looks right to me. True, this is an ionic compound; also, it is Saturday today. Both facts are equally irrelevant to the question. How 24 came about is a mystery to me. – Ivan Neretin Jun 16 '18 at 16:50

In that case, there are 8 in Mg2+, and 8 in OH- (6 from O, 1 from H, and and extra 1 because of the -1 charge). Therefore there are $8 + 2 \times 8 = 24$ per formula unit made of one Mg2+ and two OH-.