区间内的真素数
import java.util.ArrayList;
import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner scanner = new Scanner(System.in);int M = scanner.nextInt();int N = scanner.nextInt();scanner.close();ArrayList<Integer> result = findTruePrimes(M, N);if (result.isEmpty()) {System.out.println("No");} else {for (int i = 0; i < result.size(); i++) {System.out.print(result.get(i));if (i < result.size() - 1) {System.out.print(",");}}}}// 判断是否为素数private static boolean isPrime(int num) {if (num <= 1) {return false;}for (int i = 2; i <= Math.sqrt(num); i++) {if (num % i == 0) {return false;}}return true;}// 反转数字private static int reverseNumber(int num) {int reversed = 0;while (num != 0) {int digit = num % 10;reversed = reversed * 10 + digit;num /= 10;}return reversed;}// 寻找真素数private static ArrayList<Integer> findTruePrimes(int M, int N) {ArrayList<Integer> result = new ArrayList<>();for (int i = M; i <= N; i++) {if (isPrime(i) && isPrime(reverseNumber(i))) {result.add(i);}}return result;}
}