Explanation:
Rubidium is in Group 1 and exists as Rb+ ions.
Sulfur is in Group 16 and exists as S2- ions.
To form a compound containing rubidium and sulfur, the charges of the ions must be equal.
Therefore there are 2 rubidium and 1 sulfur atoms.
=> Chemical formula is Rb2S.
Sodium is also in Group 1 and exists as Na+ ions.
Oxygen is also in Group 16 and exists as O2- ions.
Therefore there are 2 sodium and 1 oxygen atoms.
=> Chemical formula is Na2O.