Fix prime number generation conditions