rendered paste body#include <stdio.h>
#include <time.h>
#define N 100
time_t start,finish;
int isprime(int );
int k,init_prime,next_prime,run,number,in_pr=0;
double duration;
main()
{
start=time(0);
init_prime=3; // oi 2 prwtoi pou anamesa tous vriskontai oi sunthetoi
next_prime=0;
run=init_prime+2;
number=0;
k=1;
while(k<N)
{
if (isprime(run))
{
next_prime=run; //vriskw ton next_prime
number=next_prime-init_prime-1; //to plhthos twn sunthetwn
in_pr=init_prime;
init_prime=next_prime;
if (number==k)
{
printf("First %d consecutive composites from %d to %d\n",k,in_pr+1,next_prime-1); //an einai o epithumhtos ton emfanizw
init_prime=3;
run=init_prime;
next_prime=0;
k+=2;
}
}
run+=2;
}
finish=time(0);
duration=difftime(finish,start);
printf("Program was executed in %lf seconds\n",duration);
}
//sunarthsh isprime()..elegxei an enas arithmos>2 einai prwtos
int isprime(int run)
{
int i=2;
int done=1;
while (done==1 && i*i<run)
{
if (run % i==0)
{
done=0;
break;
}
i++;
}
return done;
}