Why Test case 2 is failed in code editor?

import java.util.*;
public class Main {
public static void main(String args[]) {

	int n = 3;
	
	boolean isPrime = true;
	
    for(int i = 2 ; i<n ; i++) {
    	if(n%i==0) {
    		isPrime = false;
    		
    	}
    }
    
    if(n<2) isPrime=false;
	
	//System.out.println("isPrime " + isPrime);
    if(isPrime) System.out.println("Prime");
    else System.out.println("Not Prime");

}

}

@LakshmiPrasanna0303,
Corrected your code https://ide.codingblocks.com/s/185304.
Errors:

  1. Take an input in n instead of initializing it as 3.
  2. i=2; i * i <=n ; i++ when checking prime we need not go till n to check for prime. sqrt(n) is fine.
  3. Remove if(n<2) isPrime=false; this line

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.