DESKTOP-D9IGLU5_20200829-赵继豪
1 、问题
孪生素数
public class TwinPrime {
public boolean method(int n) {
for (int x = 2; x < n; x++) {
if (n % x == 0) {
return false;
}
}
return true;
}
public static void main(String[] args) {
TwinPrime t = new TwinPrime();
for (int n = 2; n < 1000; n++) {
if (t.method(n) == true && t.method(n + 2) == true) {
System.out.println(n + "和" + (n + 2));
}
}
}
}
2、吐槽
菜是原罪
点赞