Each electron in an atom is uniquely defined by three quantum numbers that indicate the electron's energy, the electron's angular momentum and the direction of the angular momentum. Two electrons are found in each electron orbital that is uniquely defined by two quantum numbers.
The electron energy n can take any integral value starting from 1.
For each value of n, there are values of the angular momentum l that can take values starting from 1. For the first 4 values of l, the orbitals are denoted as s orbital for l = 1, p orbital for l = 2, d orbital for l = 3 and f orbital for l = 4. This nomenclature is due to the type of spectroscopic lines: sharp, principal, diffuse, and fundamental
The maximum number of electrons in the s orbital is 2, for the p orbital it is 6, for the d orbital it is 10 and the f orbital can have 14 electrons.
Adding the total number of electrons in each energy shell, we get a value of 2*n^2. Or the first energy level has 2 electrons, the second can have 8 electrons, the third 18, etc.