Explanation:
In a hexagonal-close-pack (HCP) unit cell, the ratio of lattice points to octahedral holes to tetrahedral holes = 1 : 1 : 2
let the :
Number of lattice point = 1x.
Number of octahedral points = 1x
Number of tetrahedral points = 2x
If anions occupy the HCP lattice points and cations occupy half of the tetrahedral holes.
Number of anions occupying the HCP lattice points, A= 1x
Number of cations occupying the tetrahedral points, B = 
The formula of the compound will be = 
If anions occupy the HCP lattice points and cations occupy all of the tetrahedral holes.
Number of anions occupying the HCP lattice points, A= 1x
Number of cations occupying the tetrahedral points, B = 2x
The formula of the compound will be = 