# Is there any specific formula to find periodic table periods and valence electrons

I am developing a program, that uses a lot of stuff related to the periodic table. As of now, I am making a part of it the determines the period and family. I know that both of those have to do with how many valence electrons each element has. So I want to know if there are formulas to find the amount of valence electrons, family, and periods?

• Well, there's no particular rule, unless you want to also code exceptions for about a quarter of the elements. Perhaps you could ask on Math SE whether there is a function that maps atomic number to valence of the neutral atom?
– Nij
Commented Oct 1, 2016 at 0:05
• You might be reinventing the wheel. See, for instance, the python library mendeleev. I suggest looking around for what others have done - it'll save you time. Commented Oct 1, 2016 at 1:26
• You might just want to store the end of each period as an array... that saves you some time. You can also see a trend of valence electrons with some exceptions...
– DHMO
Commented Oct 1, 2016 at 1:39

The number of electrons in each orbital is double an odd number (the Pauli exclusion princilel states electrons can be in the same energy only if of opposite spin, so there can be two otherwise identical electron energy states [which can be separated in an EM field]).

• s (sharp spectral lines): 2 (twice 1)
• p (principal spectral lines): 6 (twice 3)
• d (diffuse spectral line): 10 (twice 5)
• f (fine, or "fundamental", spectral lines): 14 (twice 7)

Using that information, and the fact that the first row has only s electrons, second row s & p, usw., you should be able to calculate the first few rows easily. However, rules become much more complex for transition metals and heavier elements, where an outer shell may be added before all inner orbitals are filled.

Primary valence for the first few rows is simply the number of electrons needed to either complete the current shell (e.g. oxygen is two e- short), or revert to the previous complete, noble gas, configuration (e.g. Na minus one e- is neon). Again, there are complications, such as transition metals with multiple valences, fluorine reacting with some noble gases, usw.

• Iirc it was fundamental, not fine :) Commented Oct 2, 2016 at 2:47
• Both "fine" and "fundamental" are given in Wikipedia etymology. So much for acronyms -- TLA is a three-letter acronym ;) Commented Oct 2, 2016 at 4:21