optimize prime numbers generator