prime factor combination method working