# How to determine the molecular formula based on molecular weight, amount of substance, and partial masses of some, but not all contained elements?

I am working on a chemistry assignment and can’t figure out part of the problem.

$$\pu{0.2 mol}$$ of a compound with a molecular weight of $$82$$ contain $$\pu{9.6 g}$$ of carbon, $$\pu{1.2 g}$$ of hydrogen and the rest is nitrogen.

The question is asking for the empirical and molecular formula which I can solve, but how do you determine the amount of nitrogen?

First I assumed a $$\pu{100 g}$$ sample but that didn't get me anywhere. The empirical formula answer is supposed to be $$\ce{C2H3N}$$ but I couldn’t achieve that. Unless the book is wrong.

If you have $0.2\ \mathrm{mol}$ of a compound with $M_\mathrm{r}=82$, then you have $16.4\ \mathrm{g}$ of material. If there is only carbon, hydrogen and nitrogen present, and the carbon and hydrogen total up to $10.8\ \mathrm{g}$, then the amount of nitrogen must be $16.4\ \mathrm{g}-10.8\ \mathrm{g}=5.6\ \mathrm{g}$.
If instead you start out with 1 mole of substance, you can get the molecular formula directly. One mole would contain 48 g of carbon and 6 g hydrogen (five times more than 0.2 mole would). That would be 4 moles of carbon and 6 moles of hydrogen, i.e. $$\ce{C4H6N_x}$$. Because the molar mass is $$\pu{82 g/mol}$$ and the carbon and hydrogen only accounts for $$\pu{54 g/mol}$$, we are still missing $$\pu{28 g/mol}$$ worth of nitrogen, so $$x$$ is equal to 2. This gives a molecular formula of $$\ce{C4H6N2}$$. You get the empirical formula by dividing all subscripts by two, i.e. by the largest common divisor.
To understand this answer, you have to know that the molar masses of C, H, and N are $$\pu{12 g/mol}$$, $$\pu{1 g/mol}$$ and $$\pu{14 g/mol}$$, respectively.