Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define x 1000000
- bool mark[x+5]={false};
- void sieve()
- {
- int i,j,k=0,isprime[10000];
- mark[0]=true;
- mark[1]=true;
- for(i=2;i*i<=1000000;i++)
- {
- if(mark[i]==false)
- {
- for(j=i*i;j<=1000000;j+=i)
- {
- mark[j]=true;
- }
- }
- }
- }
- int main()
- {
- sieve();
- long long int n,i,j,k,a,b,c,d,e,f;
- while(cin>>n)
- {
- if(mark[n]==false){
- a=0, b=n;
- while(b)
- {
- a=(a*10)+b%10;
- b/=10;
- }
- if(a==n)
- cout<<n<<" is prime."<<endl;
- else if(mark[a]==false)
- cout<<n<<" is emirp."<<endl;
- else
- cout<<n<<" is prime."<<endl;
- }
- else
- cout<<n<<" is not prime."<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement