All pastes #793029 Raw Edit

Something

public text v1 · immutable
·published 2007-11-21 22:05 UTC
rendered paste body
/* File: composites.c */
#include <stdio.h>
#include <math.h>        /*Header file for sqrt function*/
#include <time.h>
#define N 113   
main()
{     time_t start,finish;
      double duration;
      int n,i,l,k,j;
      n=3;    // o epomenos prwtos  
      i=3;    // xrhsimopoieitai gia ton elegxo prwtou
      k=3;    // o arxikos prwtos arithmos
      l=1;    // plhthos pou thelw (1,3,5,..)
      j=1;    // plhthos metaxu prwtwn
       start=time(0);

      while(l<=N)
      {
                  while(j!=l||l==1)
                  {
                            while((n%i!=0&&i<=(double)sqrt(n)))
                            { 
                                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;
                  j=1;
       }
finish=time(0);
duration=difftime(finish,start);
printf("Program was executed in %lf seconds\n",duration);
}