1. The element X belongs to group 2. So, the number of valence electrons are 2 and its valency is 2.
2. The element Y belongs to group 17 or VII. So, the number of valence electrons are 7 and its valency = 8 – 7= 1.
3. During formation compound elements exchange their valencies.
∴ The formula of compound is XY2.