#include<stdio.h>
#include<math.h>
#define N 7000
bool prime[7009]={false};        // let, all are prime

void pri()
 {
    int i, j, sqrtN;
    sqrtN = int( sqrt( N ) );    // We have to check primes up to (sqrt(N))

    for( i = 3; i <= sqrtN; i += 2 ) {
        if( prime[i]== false ) {    // so, i is a prime, so, discard all the multiples
             // j = i * i, because it’s the first number to color
            for( j = i*i; j <= N; j += 2*i )
                prime[j] = true;
        }
    }        ///********* Thanks To Jan Vai ********
}

int main()
{
    pri();
    int i,j=0;               
    printf("2 ");        // print the primes

    for( i = 3; i <= N; i += 2 ) { // increment is 2, to avoid the even number
        if( prime[i] == false ) {
            printf("%d ", i);
                ++j;
        }
        if(j%25==0)
            puts("");   
    }

    printf("\n\n******** The total prime number is %d *******\n",j);
    return 0;
}