All pastes #792652 Raw Edit

Something

public text v1 · immutable
·published 2007-11-21 16:30 UTC
rendered paste body
* File: composites.c */
#include <stdio.h>
#include <stdlib.h>        /* Header file for srand and rand functions */
#include <math.h>        /*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();
}