A chemical formula is the representation of substance by symbols and it denotes the number of atoms of each element present in the compound. To write a formula one must know the symbols and valencies of the elements.The valency of Hg=2 and of Cl=1 so the formula is HgCl2.