loop over possible quantum numbers