MIPI_BaseC_WebinarFRTK/21_Seminar08/06_isPrime_refact_p25.c

24 lines
437 B
C
Raw Permalink Normal View History

2024-11-13 09:22:28 +03:00
#include <stdio.h>
int main(int argc, char **argv)
{
int arr[255] = {2,3};
int capacity = 2;
int i,j;
for(i=4;i<255;++i)
{
int isPrime=1;
for(j=0;j<capacity;++j)
if(i%arr[j] ==0)
{
isPrime=0;
break;
}
if(isPrime)
arr[capacity++]=i;
}
for(i=0;i<capacity;++i)
printf("%d ",arr[i]);
return 0;
}