The factor comes about during the calculation of the first-order perturbation in the energy of an atom when a weak uniform magnetic field (that is, weak in comparison to the system's internal magnetic field) is applied to the system. Formally we can write the factor as,
The orbital is equal to 1, and under the approximation , the above expression simplifies to
Here, J is the total electronic angular momentum, L is the orbital angular momentum, and S is the spin angular momentum. Because for electrons, one often sees this formula written with 3/4 in place of . The quantities gL and gS are other g-factors of an electron. You should note that for an atom, and for an atom, .
If we wish to know the g-factor for an atom with total atomic angular momentum (nucleus + electrons), such that the total atomic angular momentum quantum number can take values of , giving
Here is the Bohr magneton and is the nuclear magneton. This last approximation is justified because is smaller than by the ratio of the electron mass to the proton mass.
The following derivation basically follows the line of thought in  and.
Both orbital angular momentum and spin angular momentum of electron contribute to the magnetic moment. In particular, each of them alone contributes to the magnetic moment by the following form
Note that negative signs in the above expressions are because an electron carries negative charge, and the value of can be derived naturally from Dirac's equation. The total magnetic moment , as a vector operator, does not lie on the direction of total angular momentum , because the g-factors for orbital and spin part are different. However, due to Wigner-Eckart theorem, its expectation value does effectively lie on the direction of which can be employed in the determination of the g-factor according to the rules of angular momentum coupling. In particular, the g-factor is defined as a consequence of the theorem itself