Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5.     int N,i;
  6.     while(cin>>N)
  7.        {
  8.          int  r=0,j,c=0,y=0,t;
  9.          int x=N;
  10.  
  11.         for(i=2; i*i<=N; i++)
  12.         {
  13.             if((N%i)==0)
  14.             {
  15.                 c++;
  16.             }
  17.         }
  18.  
  19.         if(c==0)
  20.         {
  21.             while(N>0)
  22.             {
  23.                 t=N%10;
  24.                 N=N/10;
  25.                 r=r*10+t;
  26.             }
  27.  
  28.             for(j=2; j*j<=r; j++)
  29.             {
  30.                 if(r%j==0)
  31.                 {
  32.                     y++;
  33.                 }
  34.             }
  35.             if(y>0 || x==r)
  36.             {
  37.                 printf("%d is  prime.\n",x);
  38.  
  39.             }
  40.             else if(y==0 && x!=r )
  41.             {
  42.                 printf("%d is emirp.\n",x);
  43.             }
  44.  
  45.         }
  46.  
  47.         else
  48.         {
  49.             printf("%d is not prime.\n",x);
  50.         }
  51.        }
  52.        return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement