From the close packed structure, it is clear that :
Contribution of atoms of X present at the corners `=8xx1//8=1`
Contribution of atoms of X present at the face corners `=6xx1//2=3`
Total no. of atoms of X present in one unit cell `=1+3=4`
Contribution of atoms of M present at edge centers = `4xx1//4=1`
Contribution of atoms of M present at body centre = 1
Total no. of atoms of X present in one unit cell `=1+1=2`
Ratio of the atoms of `M:X::2:4::1:2`
Formula of the compound `=MX_(2)`.