skb50bd

Twin Prime

Apr 18th, 2015
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.38 KB | None | 0 0
  1. #include<stdio.h>
  2. int isprime(int x)
  3. {
  4.     int i;
  5.     for(i=2 ; i*i<=x ; i++)
  6.         if(x%i==0)
  7.             return 0;
  8.     if(i*i>x)
  9.         return 1;
  10. }
  11.  
  12. int main()
  13. {
  14.     int n, a, b;
  15.  
  16.     printf("Enter Limit: "),
  17.     scanf("%d",&n);
  18.  
  19.     for(a=3, b=5 ; b<=n ; a+=2, b+=2)
  20.         if(isprime(a)==1 && isprime(b)==1)
  21.             printf("%d %d\n",a,b);
  22.     return 0;
  23. }
Add Comment
Please, Sign In to add comment