-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10235.cpp
63 lines (56 loc) · 915 Bytes
/
10235.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
10235 - Simply Emirp
*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long i,c,d,num,j,p,n;
while(scanf("%lld",&num)==1)
{
p=num;
i=2;
while(i<=num)
{
if(num%i==0)
break;
i++;
}
n=0;
while(num!=0)
{
n=n*10+num%10;
num/=10;
}
j=2;
while(j<=n)
{
if(n%j==0)
break;
j++;
}
if(p==2)
printf("%lld is prime.\n",p);
else if((j==n)&&(i==p))
printf("%lld is erime.\n",p);
else if(i==p)
printf("%lld is prime.\n",p);
else
printf("%lld is not prime.\n",p);
}
return 0;
}
/*
Sample Input
17
18
19
179
199
Sample Output
17 is emirp.
18 is not prime.
19 is prime.
179 is emirp.
199 is emirp.
*/