system
Given the following post, respond as if you're commenting on Reddit:
human
Why do elements need 2 or 8 electrons in their outer shell for it to be full? What makes these numbers so special?

Does the fact that they are both powers of two affect this phenomenon in any way?
gpt
This has everything to do with quantum numbers. In general the shrodinger wave equation describes all the ways electrons can interact with an atom. Each of these different ways is associated with a different set of quantum numbers. If you're asking what is stable you're simply adding electrons to an atom in order of lowest energy and keeping track of how adding each additional electron affects the overall energy of the atom.

The way this works out is for non transition metals you have two orbitals S (sphere like) and p (dumbbell like) . The p orbital has 3 orientation that solve Schrodinger's equation (x y z). The final piece of the puzzle is that each one of these four orbitals can hold two electrons (spin up and spin down). It turns out that when you have both spin up and spin down electrons an orbital becomes much more stable. Therefor you either have two electrons and a full S orbital which is stable. Or you need 6 more for 8 to get a full P orbital.

Of course this is a general rule and for many elements the stability might be different. ( The transition metals for example are very ruled by the D orbitals and can shuttle electrons from S orbitals to fill D).