Geometrical symmetry of the molecule and the polarity of the bonds determine the polarity of the molecule.
The molecule that has zero dipole moment that means it is a geometrically symmetric molecule and the molecule which has some net dipole moment means it is a geometrically asymmetric molecule.
As the molecule is symmetric, the dipole moment will be zero as dipole moments cancel each other and the molecule will be non-polar.
As the molecule is asymmetric, the dipole moment will not be zero and the molecule will be polar.
For this, you can plug in 2 everywhere you see an n. So the equation will read: g(2)=g(2-1)+2 -> g(2)=g(1)+2. Since we are given g(1)=0, we can plug in 0 where we see g(1). The equation is now. g(2)=0+2. So, g(2)=2.