Prime visits doubt 2

public boolean isPrime(int n) {
if (n <= 1) {
return false;
}
for (int i = 2; i < Math.sqrt(n); i++) {
if (n % i == 0) {
return false;
}
}
return true;
}==========see i have improved logic still i not getting correct answer

check ur code for the input 25
25 is not a prime no.

that’s what i m asking what is error in logic?

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.

make ur loop upto <=Math.sqrt(n)

for 25
ur loop is executing upto 4
it should be upto 5