参考代码:
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); boolean boo = true; for (int i = 2; i < n; i++) { for (int j = 2; j <= i/2; j++) { if ((i%j) == 0){ boo = false; break; } } if (boo && n%i==0){ System.out.println(i); } boo = true; } } }
0.0分
1 人评分