Advertisement
noor017

Prime Number

Jul 2nd, 2015
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.48 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int n,i,a,total=0,j;
  5.  
  6.     scanf("%d",&n);
  7.  
  8.     while(n--)
  9.     {
  10.         scanf("%d",&a);
  11.  
  12.         for(j=1;j<=a;j++)
  13.         {
  14.             if(a%j==0)
  15.             {
  16.                 total++;
  17.             }
  18.         }
  19.  
  20.         if(total==2)
  21.         {
  22.             printf("%d eh primo\n",total);
  23.         }
  24.  
  25.         else
  26.         {
  27.             printf("%d nao eh primo\n",total);
  28.         }
  29.  
  30.         total=0;
  31.  
  32.     }
  33.  
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement