molecular mass of nitrogen, N2 = 2*14 = 28
molecular mass of hydrogen, H2=2*1 = 2
Molecules of both elements contain 2 atoms, so the ratio of molecules is the same as the ratio of atoms.
From the molecular masses above,
ratio of number of molecules = ratio of molecular masses, therefore
7g N2 : x g H2 = 28:2
cross multiply:
x=7*2/28=0.5 g of Hydrogen has the same number of atoms as 7 g of nitrogen (at room temperatures)