In high school I was taught to merely use the cations charge as the anions subscript, and reverse. For example, CaCl2 could be found by saying that Ca is Ca2+ and Cl1- We would then "criss cross" (That's what she called it... The "Criss cross" method, oh public high school, you) To get Ca1Cl2 and as we all know, 1 in chem is understood so, we end up with just CaCl2
You then reduce the subscripts by there GCF so Ca2O2 may be reduced by the GCF of 2, to simply CaO.
Nothing new there, just hoping to help explain it.