Magic numbers are typically obtained by empirical studies; if the form of the nuclear potential is known, then the Schrödinger equation can be solved for the motion of nucleons and energy levels determined. Nuclear shells are said to occur when the separation between energy levels is significantly greater than the local mean separation.
In the shell model for the nucleus, magic numbers are the numbers of nucleons at which a shell is filled. For instance, the magic number 8 occurs when the 1s, 1p, 1p energy levels are filled, as there is a large energy gap between the 1p and the next highest 1d energy levels.
The atomic analog to nuclear magic numbers are those numbers of electrons leading to discontinuities in the ionization energy.  These occur for the noble gases helium, neon, argon, krypton, xenon, radon and oganesson. Hence, the "atomic magic numbers" are 2, 10, 18, 36, 54, 86 and 118. As with the nuclear magic numbers, these are expected to be changed in the superheavy region due to spin/orbit-coupling effects affecting subshell energy levels. Hence copernicium (112) and flerovium (114) are expected to be more inert than oganesson (118), and the next noble gas after these is expected to occur at element 172 rather than 168 (which would continue the pattern).
In 2010, an alternative explanation of magic numbers was given in terms of symmetry considerations. Based on the fractional extension of the standard rotation group, the ground state properties (including the magic numbers) for metallic clusters  and nuclei were simultaneously determined analytically. A specific potential term is not necessary in this model.