solve problem5, but still trying to write general procedure for solving. have sieve and proposed method (need fix)