#include "iostream"
#include <cmath>
using namespace std;
int main()
{
int value;
cout << "Input value >=10 : ";
cin >> value;
if (value < 10 )
{
cout << "Too small." << endl;
return 0;
}
int i;
for (i = 10; i < value; i++)
{
int temp = i;
int check = 0;
int times = 0;
for (int j = 2; j < temp / 2; j++)
{
if (temp%j == 0)
{
check = 1;
break;
}
}
if (check == 1);
else
{
int new_temp = temp;
do
{
times++;
new_temp = new_temp / 10;
} while (new_temp >= 10);
int perm = pow(10, times);
for (int k = 0; k < times; k++)
{
temp = (temp % perm)*10 + temp / perm;
for (int j = 2; j < temp / 2; j++)
{
if (temp%j == 0)
{
check = -1;
break;
}
}
if (check != -1) check++;
}
if (check == times)
{
cout << i << endl;
}
}
}
system("pause");
return 0;
}
Comments
Leave a comment