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
Though it's very old post, Following is my try to generate the prime number using "Sieve of Eratosthenes" algorithm.
#include
#define NUM 8000 /* Prime Numbers in the Range. 'Range + 2' actually. */
int main()
{
int a[NUM] = {0}; /* Array which is going to hold all the numbers */
int i , j;
/* initializing array from 2 to given number + 2, assuming the first prime number is 2 */
for(i = 2,j=0; i < NUM+2, j
Hope this will help someone.