Read in your tongue here..

Showing posts with label Twin Prime Numbers. Show all posts
Showing posts with label Twin Prime Numbers. Show all posts

Friday, June 28, 2013

Twin Prime Numbers

void main()
{
     int t=0,x,n=1,i,p=0,n2;
     printf("Enter number of terms:");
     scanf("%d",&x);
     while(t<x)
     {
     for(i=1;i<=n;i++)
           if(n%i==0)
                p++;
     if(p==2)
     {
           p=0;
           n2=n+2;
           for(i=1;i<=n2;i++)
                if(n2%i==0)
                     p++;
           if(p==2)
           {
                printf("(%d,%d) ",n,n2);
                t++;
           }
     }
     p=0;
     n+=2;
     }
     getch();
     clrscr();
}