How to find the number of hydrogen atoms in 0.5 mol of hydrogen gas?
There is no need to use 
$$n = \frac{m}{M},$$ 
since you already have been given the amount of substance. You would need to use the equation, if you were given the mass $m$, e.g. as $\pu{0.5 mg}$. 

If you want to calculate the number of hydrogen atoms in $\pu{0.5 mol}$ hydrogen gas, then you should consider that they are diatomic molecules, $\ce{H2}$.
The unit mole is represented by the Avogadro constant and is 
$$N_\mathrm{A} = \pu{6.02214076×10^23 mol−1} 
\approx \pu{6.022×10^23 mol−1}$$ 
Each hydrogen molecule has two hydrogen atoms, therefore
\begin{align}
n(\ce{H}) &amp;= 2 \cdot n(\ce{H2}),\\
N(\ce{H}) &amp;= n(\ce{H}) \cdot N_\mathrm{A},\\
N(\ce{H}) &amp;= 2 \cdot n(\ce{H2}) \cdot N_\mathrm{A},\\
N(\ce{H}) &amp;= 2 \times \pu{0.5 mol} \times \pu{6.022×10^23 mol−1},\\
N(\ce{H}) &amp;= \pu{6.022×10^23}.
\end{align}