Can anyone tell me how to implement Sieve of Eratosthenes algorithm in C? I need to generate prime numbers but my algorithm is slow.
My code:
#inclu
Here is actually very simple code that use the Sieve of Eratosthenes algorithm. works for all positive int.
int
int is_prime(int n){ int p; for(p = 2; p < n; p++){ if(n % p ==0 && p != n) return 0; } return 1; }