-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10235.cpp
70 lines (60 loc) · 1.16 KB
/
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
64
65
66
67
68
#include<stdio.h>
#include<math.h>
long long int invrc(long long int a);
long long int prime(long long int b);
int main()
{
long long int e,f,g=0,h=0;
while(scanf("%lld",&e)==1)
{
if(e==1)
printf("%lld is prime.\n",e);
else if(e==2)
printf("%lld is prime.\n",e);
else if(e==3)
printf("%lld is prime.\n",e);
else if(e==4)
printf("%lld is not prime.\n",e);
else{
f=prime(e);
if(f==0)
{
g=invrc(e);
h=prime(g);
if(h==0&&e>9){
printf("%lld is emirp.\n",e);
}
else{
printf("%lld is prime.\n",e);
}
}
else
printf("%lld is not prime.\n",e);
}
}
return 0;
}
long long int invrc(long long int a)
{
long long int b,c=0,d=0,e=0;
b=a;
while(b!=0){
e=b/10;
c=b%10;
d=d*10+c;
b=e;
}
return d;
}
long long int prime(long long int b)
{
long long int i,v=0;
for(i=2;i<=b/2;i++)
{
if(b%i==0){
v++;
break;
}
}
return v;
}