my program is intended to check if a number inputted by the user is prime, unfortunately the '!isPrime' part if the while loop doesnt stop the while loop if it finds a factor of the number inputted, and it just carries on.. would love if anyone could tell me why it isnt working . thanks
class Prime{
public static void main(String args[]){
long n;
boolean isPrime=false;
MaInput Ma = new MaInput();
int i=2;
n=Ma.readLong("Input a number, please!");
while(!isPrime||i<n){
if(n%i==0){
isPrime=false;
System.out.println(n+" is not prime");
}
else{
isPrime=true;
System.out.println(n+" is prime");
}
i++;
}
}
}