#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
int main(){
int n, m, mod, l, rev;
while(cin >> n){
m = n;
int prove = 0;
for(int i = 2; i <= sqrt(n); i++)
if(n%i == 0){
prove = 1;break;
}
rev = 0;
if(prove == 0){
while(m > 0){
mod = m % 10;
rev = (rev*10) + mod;
m /= 10;
}
int rev_ans = 0;
for(int i = 2; i <= sqrt(rev); i++)
if(rev%i == 0){
rev_ans = 1;break;
}
if(rev == n)rev_ans = 1;
if(rev_ans == 0)cout << n << " is emirp." << endl;
else cout << n << " is prime." << endl;
}
else cout << n << " is not prime." << endl;
}
return 0;
}
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
int main(){
int n, m, mod, l, rev;
while(cin >> n){
m = n;
int prove = 0;
for(int i = 2; i <= sqrt(n); i++)
if(n%i == 0){
prove = 1;break;
}
rev = 0;
if(prove == 0){
while(m > 0){
mod = m % 10;
rev = (rev*10) + mod;
m /= 10;
}
int rev_ans = 0;
for(int i = 2; i <= sqrt(rev); i++)
if(rev%i == 0){
rev_ans = 1;break;
}
if(rev == n)rev_ans = 1;
if(rev_ans == 0)cout << n << " is emirp." << endl;
else cout << n << " is prime." << endl;
}
else cout << n << " is not prime." << endl;
}
return 0;
}
No comments:
Post a Comment