The valency of an element measures its ability to combine with other elements. The valency is determined by the number of electrons in the outer shell of each atom of an element. All atoms with two or more electron shells are most stable when they have eight electrons in their outer shell, but only a few elements are naturally formed that way (neon, for example), and most that just have one or two electrons in their outer shell (lithium, for example) or six or seven (oxygen, for example) tend to react, or combine their outer-shell electrons with the outer-shell electrons of other adjacent elements to bond and form more stable multi-element molecules.
Consult the periodic table of the elements to determine the valency of an element. The periodic table is organised by groups in rows and columns, and the elements of groups I-VIII have the same valency as others in their group.
All the elements in group VIII have eight electrons in their outer shells, and thus have a valency of zero (highly stable). Elements in group I just have one valent electron in their outer shells and thus have a valency of one, which means they are very reactive. Group IV/valency 4 elements like carbon are relatively stable. Group VI and VII elements like oxygen are also reactive as they seek electron pairs to complete their outer shell octet.
Calculate the valency of an element using the total number of electrons. The valency of an atom is equal to the number of electrons in the outer shell if that number is four or less. Otherwise, the valency is equal to eight minus the number of electrons in the outer shell. The number of electrons in each shell of an atom is regular so if you know the number of electrons in the atom, then you can calculate the valency. All atoms (except hydrogen) have two electrons in the first electron shell, and up to eight electrons in each succeeding electron shell. For example, carbon has six electrons, two in the first shell, and four in the outer shell, giving it a valency of four. Oxygen has eight electrons, two in the first shell and six in the outer shell, giving it a valency of two (8 - 6 = 2).
Calculate the valency of multi-element molecules using the same procedure. For example, to determine the valency of the ionic molecule phosphorus tetraoxide (PO4, four atoms of oxygen and one atom phosphorus) you multiply the total valency of the four oxygen atoms (valency 2) and subtract that from the valency of the phosphorus atom (valency 5). That reveals the valency of PO4 is 3.