// program that prints all the Euclid numbers until the first composite // Euclid number is reached.The program implements the following two // functions (other than the main): // 1. int isprime(int n): returns 1 if n is prime, 0 otherwise // 2. int primorial(int n): returns the primorial of n // // Author:rahule@cse.iitk.ac.in // #include int isprime(int); // returns 1 if n is prime, 0 otherwise int primorial(int); // returns the primorial of n main() { int i,e; for(i=1;;i++) //Runs till a composite Euclid number is found.the "condition" of "for loop" is left blank,since we are not checking for a condition. //the loop breaks once a composite Euclid number is found { e=primorial(i)+1; //calculates ith Euclid numer if(!isprime(e)) //checks whether it is NOT prime.If NOT prime,breaks. break; else //if it is prime,prints it printf("the %dth Euclid number is: %d\n",i,e); } printf("\nthe %dth Euclid number %d is composite! exiting..\n",i,e); //prints the first Euclid number which is a composite number } int primorial(int n) // returns the primorial of n { int cnt=0,i=2,p=1; if(n==0) //base case.p(0)=1 return(1); while(cnt