@Peilonrayz hit the point by mentioning the real problem with your your implementation design which is the algorithm complexity. So I want to go further: AFAIK, the fastest known algorithm that prime numbers generator is Sieve of Atkin. You should consider this algorithm as a starting point for an effective solution for the sake of algorithm complexity.
                
                    Billal BEGUERADJ 
                
                
- 1
 - 10
 - 25
 - 35