Group of an element can be calculated based on the number of valency electrons present in the atom of the element.
the electron configuration is written - by filling the orbitals and shells - with the electrons the atom has. Then the number of valency electrons in the outer most shell of the atom, is the group of the atom.
Hydrogen has 1 electron in shell K = 1, 1s1. Hence it is in group 1.
Chlorine has 7 valency electrons in it. It is in group 7. It has 17 electrons. as: 1s2, 2s2, 2p6, 3s2, 3p5.