#include <stdio.h>
#include <stdlib.h>
#define NUM 10000
void main()
{
int primeNumber[NUM] = { 0, };
int i = 0;
int j = 0;
for( i = 1; i < NUM; i++ )
primeNumber[i] = i;
for( i = 2; i < NUM; i++ ) {
for( j = i + 1; j < NUM;j++ ) {
if( primeNumber[j] % i == 0 )
primeNumber[j] = 1;
}
}
j = 0;
for( i = 1; i < NUM ; i++ ) {
if( primeNumber[i] != 1) {
j++;
printf( "%5d ", primeNumber[i] );
if( j % 10 == 0 ) {
printf( "\n" );
j = 0;
}
}
}
printf( "\n" );
}
댓글 쓰기