You are viewing a single comment's thread. Return to all comments →
public static void main(String[] args) { Scanner in = new Scanner(System.in); List<Integer> list=new ArrayList<>(); int t = in.nextInt(); for(int a0 = 0; a0 < t; a0++){ int n = in.nextInt(); list.add(n); } int max=list.stream().max(Integer::compare).orElse(0); Map<Integer,Integer> map= new LinkedHashMap<>(); int count; int x=0; int i=2; while(x<=max){ count=0; for(int j=2;j<=i/2;j++){ if(i%j==0 ){ count++; break; }else{ continue; } } if(count==0){ x++; map.put(x, i); } i++; } for(int k=0;k<list.size();k++){ System.out.println(map.get(list.get(k))); } }
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 →
Java