int n = 500; // 替换为你想要的 n 值 int primeCount = countPrimes(n); System.out.println("2 到 " n " 之间的素数个数为:" primeCount); } public static int countPrimes(int n) { int count = 0; for (int i = 2; i <= n; i ) { if (isPrime(i)) { count ; ...