Advertisement
Nayeemzaman

prime with function

Dec 19th, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.42 KB | None | 0 0
  1. #include<stdio.h>
  2. int is_prime(int n)
  3. {
  4.     int i,ct=0;
  5.     for(i=2;i<n;i++)
  6.     {
  7.         if(n%i==0)
  8.         {
  9.             ct++;
  10.             break;
  11.         }
  12.     }
  13.     if(ct>0 || n==1)
  14.         return 1;
  15.     else
  16.         return 0;
  17. }
  18. int main()
  19. {
  20.     int n,x;
  21.     scanf("%d",&n);
  22.     x= is_prime(n);
  23.     if(x==1)
  24.         printf("Not Prime\n");
  25.     else if(x==0)
  26.         printf("Prime\n");
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement