import java.util.*;
class Testmethod {
public boolean testsushu(int numbers) {
for (int i = 2; i <= numbers / 2; i++) {
if (numbers % i == 0) {
return false;
}
}
return true;
}
public boolean testhuiwenshu(int numbers) {
int x = 0;
int code = 0;
if (numbers < 10) {
return true;
}
while (numbers > x) {
x = x * 10 + numbers % 10;
numbers /= 10;
code++;
}
if (code % 2 != 0) {
if (x == numbers) {
return true;
} else {
return false;
}
} else {
if (x / 10 == numbers) {
return true;
} else {
return false;
}
}
}
}
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = 0;
int b = 0;
int count = 0;
a = sc.nextInt();
b = sc.nextInt();
Testmethod test = new Testmethod();
for (int i = a; i <= b; i++) {
if (test.testsushu(i) && test.testhuiwenshu(i)) {
System.out.println(i);
count++;
}
}
System.out.println(a + "~" + b + "之间共有" + count + "个符合要求!");
}
}
运行结果如下: