You are viewing a single comment's thread. Return to all comments →
Java Solution
Scanner sc = new Scanner(System.in); int n = sc.nextInt(); for(int j=n;j>0;j--) { int a = sc.nextInt(); boolean pr = true; if(a==1) { System.out.println("Not prime"); continue; } for(int i=2;i<=a/2;i++) { if(a%i==0) { pr = false; System.out.println("Not prime"); break; } } if(pr==true) { System.out.println("Prime"); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Day 25: Running Time and Complexity
You are viewing a single comment's thread. Return to all comments →
Java Solution