* File: composites.c */ #include #include /* Header file for srand and rand functions */ #include /*Header file for sqrt function*/ #define N 30 main() { int n,i,l,k,j; n=3; i=3; k=3; l=1; j=1; while(l<=N){ while(j!=l||l==1){ while((n%i!=0&&i<=(double)sqrt(n))||n==i){i=i+2;}; if(n%i!=0&&i>(double)sqrt(n)){ if(n-k-1==l){ printf("first %d consecutive composites from %d to %d \n",l,k+1,n-1); l=l+2; j=l; }; }; if(l!=1&&n%i!=0&&i>(double)sqrt(n)) {k=n;}; i=3; n=n+2; } n=3; }; getchar(); }