The quantum numbers of an electron are n (determined by electron's energy), l (angular momentum), `m_l` (one component of angular momentum) and `m_s` (spin, or intrinsic magnetic moment), and they have to obey certain restrictions, which are:
`0 <=l<=n-1` (l is an integer)
`-l<=m_l<=l` (`m_l` is an integer)
`m_s` is a positive or negative half-integer.
So for n = 1, the only possible value of l is l=0, so `m_l = 0` as well and `m_s` can be + or - 1/2. So there are two possible electrons for n = 1.
For n = 2, the possible values of l are 0 and 1.
If l = 0, then `m_l = 0` and there are two possible values of `m_s` .
If l = 1, then `m_l` can be -1, 0, or 1, and for each of these there are two possible values of `m_s` .
Thus, for n = 2, there are 2 + 3*2 = 8 possible electrons.
For n = 3, l can be 0, 1, and 2.
As discussed above, there will be 2 electrons with l = 0 and 6 electrons with l = 1.
If l = 2, there will be 5 possible values of `m_l` : -2, -1, 0, 1, 2, and each of these electrons have +1/2 or -1/2 spin (`m_s` .
So for n = 3, there are 2 + 6 + 2*5 = 18 electrons.
To sum up:
n=1 : 2 electrons
n=2: 8 electrons
n=3: 18 electrons
Further Reading