Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int N,i;
- while(cin>>N)
- {
- int r=0,j,c=0,y=0,t;
- int x=N;
- for(i=2; i*i<=N; i++)
- {
- if((N%i)==0)
- {
- c++;
- }
- }
- if(c==0)
- {
- while(N>0)
- {
- t=N%10;
- N=N/10;
- r=r*10+t;
- }
- for(j=2; j*j<=r; j++)
- {
- if(r%j==0)
- {
- y++;
- }
- }
- if(y>0 || x==r)
- {
- printf("%d is prime.\n",x);
- }
- else if(y==0 && x!=r )
- {
- printf("%d is emirp.\n",x);
- }
- }
- else
- {
- printf("%d is not prime.\n",x);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement