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?

  • $\begingroup$ 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? $\endgroup$
    – Nij
    Commented Oct 1, 2016 at 0:05
  • 1
    $\begingroup$ 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. $\endgroup$ Commented Oct 1, 2016 at 1:26
  • $\begingroup$ 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... $\endgroup$
    – DHMO
    Commented Oct 1, 2016 at 1:39

1 Answer 1


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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.