solve 006-007, and refactor PrimeFactory by using generator