given an integer, write code to list all primes preceding it.
Utilisateur anonyme
This solution can be optimized further. No need to check for even numbers (except 2, 2 is the only prime even number). You can find if 'n' is prime when it is not divisible by any number between 2 to n/2. More optimizaton can be achieved if the range is reduced further from 2 to sqrt(n). But finding a sqrt will be tedious and might require inclusion of math.h library.