Advertisement
Farjana_akter

Untitled

Mar 12th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define x 1000000
  4. bool mark[x+5]={false};
  5. void sieve()
  6. {
  7. int i,j,k=0,isprime[10000];
  8. mark[0]=true;
  9. mark[1]=true;
  10. for(i=2;i*i<=1000000;i++)
  11. {
  12. if(mark[i]==false)
  13. {
  14. for(j=i*i;j<=1000000;j+=i)
  15. {
  16. mark[j]=true;
  17. }
  18. }
  19. }
  20. }
  21. int main()
  22. {
  23. sieve();
  24. long long int n,i,j,k,a,b,c,d,e,f;
  25. while(cin>>n)
  26. {
  27. if(mark[n]==false){
  28. a=0, b=n;
  29. while(b)
  30. {
  31. a=(a*10)+b%10;
  32. b/=10;
  33. }
  34. if(a==n)
  35. cout<<n<<" is prime."<<endl;
  36. else if(mark[a]==false)
  37. cout<<n<<" is emirp."<<endl;
  38. else
  39. cout<<n<<" is prime."<<endl;
  40. }
  41. else
  42. cout<<n<<" is not prime."<<endl;
  43. }
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement