In chemistry, a mole is a quantity unit that stands for the amount of a given substance. One mole of any chemical compound contains 6.022 x 10^23 molecules, a number also known as the Avogadro constant. Thus, to calculate the number of molecules, you only need to know the mass of the substance and its chemical formula. From there you can calculate the number of moles in the sample and, from that figure, the number of molecules.
Note the chemical formula of the compound. For example, if the compound is sodium sulfate, Na2SO4, each molecule contains two atoms of sodium (Na), one atom of sulfur (S) and four atoms of oxygen (O).
Find the element symbols in the Periodic Table of the Elements, and write down the atomic weights of each element. In our example, the atomic weight of sodium (Na) is 23; sulfur (S) is 32; and oxygen (O), 16.
Multiply the atomic weight of each element by the number of atoms of the element in the molecule, and add these to calculate the compound molar mass. In the example, the molar mass of Na2SO4 is (23 x 2) + (32 x 1) + (16 x 4) = 142 grams per mole.
Divide the known mass of the compound by its molar mass to calculate the number of moles. For example, suppose the mass of your sample of Na2SO4 is 20 g. The number of moles equals 20 grams /142 grams/mole = 0.141 moles.
Multiply the number of moles by the Avogadro constant, 6.022 x 10^23, to calculate the number of molecules in your sample. In the example, the number of molecules of Na2SO4 is 0.141 x 6.022 x 10^23, or 8.491 x 10^22 molecules of Na2SO4.