Torry 的困惑
- 是找前n项质数和 而不是说前n项自然数的质数积
- 里面用了一种新的找质数的方法
https://blog.csdn.net/kevin_nan/article/details/88300966 里面有写新的质数查找方法
public class main{ public long countPrimes(int n) { long sum = 1; int n2 = 0; boolean[]arr = new boolean [10000000+1]; for(int i = 2 ;i < 10000000+1 ;i++) { int j = 2; if(arr[i]!=true) while(j * i < 10000000+1 ) { arr[j * i ] = true; j++; } } for(int i = 2 ;i< 10000000+1 ;i++) { if(arr[i] != true) { sum = (sum*i)%50000; n2 ++ ; } if(n2 >= n) break; } return sum; } public static void main(String[]args) { Main1 m = new Main1 (); Scanner sc = new Scanner (System.in); int n = sc.nextInt(); System.out.println(m.countPrimes(n)); } }