/**
* ListPrime.c
*/
#include
#include
#include
void fun(unsigned m, unsigned *XX, unsigned *cnt){
unsigned i=3;
*cnt = 0;
if(m<=2)
return;
XX[0] = 2;
*cnt += 1;
for(; i unsigned max = (unsigned)ceil(sqrt((float)i));
short isPrime = 1;
unsigned j=2;
for(; j<=max; j++){
if(i%j)
continue;
isPrime = 0;
break;
}
if(isPrime){
XX[*cnt] = i;
*cnt += 1;
}
}
}
int main(){
unsigned m = 0;
unsigned *XX = NULL;
unsigned count = 0;
unsigned i=0;
unsigned *A = NULL;
scanf("%d", &m);
XX = (unsigned*)malloc(sizeof(unsigned)*m);
if(!XX){
printf("Failed to malloc!\n");
return -1;
}
fun(m, XX, &count);
printf("There is(are) %u prime number(s).\n", count);
for(; i printf("%d\t", XX[i]);
free(XX);
return 0;
}