1. 题目
读题
考查点
2. 解法
思路
代码逻辑
具体实现
public class HJ60 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
getPrimeNum(n);
}
public static void getPrimeNum(int n) {
int first = 0, second = 0, diff = n;
for (int i = n / 2; i >= 2; i--) {
if (Math.abs(n - 2 * i) < diff && isPrime(i) && isPrime(n - i)) {
first = i;
second = n - i;
diff = Math.abs(second - first);
}
}
if (first != 0) {
System.out.println(first);
System.out.println(second);
}
}
public static boolean isPrime(int n) {
boolean flag = true;
for (int i = 2; i * i <= n; i++) {
if (n % i == 0) {
return false;
}
}
return true;
}
}