optimizing permutation algorithm to not include numbers smaller than original one