#include<bits/stdc++.h>
#define ll unsigned long long int
#define N 10000000
using namespace std;
int p[N+1];
void prime()
{
ll l = sqrt(N), i, j;
p[0] = p[1] = 1;
for(i=2;i<=l;i++)
{
if(p[i] == 0)
{
for(j=2;i*j<N;j++)
p[i*j] = 1;
}
}
}
int check(ll n)
{
string s = to_string(n), r;
r = s;
reverse(r.begin(), r.end());
if(s == r)
{
if(p[n] == 0)
return 1;
else
return 0;
}
else
return 0;
}
int main()
{
prime();
ll n, m;
while(cin >> n)
{
cout << n*2 << endl;
int t1 = check(n);
if(t1 == 1)
break;
}
return 0;
}
#define ll unsigned long long int
#define N 10000000
using namespace std;
int p[N+1];
void prime()
{
ll l = sqrt(N), i, j;
p[0] = p[1] = 1;
for(i=2;i<=l;i++)
{
if(p[i] == 0)
{
for(j=2;i*j<N;j++)
p[i*j] = 1;
}
}
}
int check(ll n)
{
string s = to_string(n), r;
r = s;
reverse(r.begin(), r.end());
if(s == r)
{
if(p[n] == 0)
return 1;
else
return 0;
}
else
return 0;
}
int main()
{
prime();
ll n, m;
while(cin >> n)
{
cout << n*2 << endl;
int t1 = check(n);
if(t1 == 1)
break;
}
return 0;
}
Comments
Post a Comment