You are viewing a single comment's thread. Return to all comments →
Two test cases are failing, can anyone help me find what is wrong:
import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*;
public class Solution {
public static void main(String[] args) { Scanner in = new Scanner(System.in); // int flag=0; boolean prime[]=new boolean[10001]; Arrays.fill(prime,true); prime[0]=false; prime[1]=false; for(int p=2;p<=10000;p++) { if(prime[p]==true) { for (int i = p * p; i <= 10000; i += p) prime[i] = false; } } int t = in.nextInt(); for(int a0 = 0; a0 < t; a0++){ int n = in.nextInt(),st=-1; for(int i=0;i<10000;i++) { if(prime[i]==true && n!=0) { n--; st=i; } } System.out.println(st); } }
}
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #7: 10001st prime
You are viewing a single comment's thread. Return to all comments →
Two test cases are failing, can anyone help me find what is wrong:
import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*;
public class Solution {
}