I'm starting the programming and always try to unravel the things that are not clear, so far I have, but here I tried and tried and could not understand why the program did not increase the value 5 being that less than 5.5
public class Primo {
public static boolean ehPrimo(float nr) {
if (nr < 2)
return false;
for (float i = 2; i <= (nr / 2); i++) {
if (nr % i == 0)
return false;
System.out.println("nr = " + nr + "\ti = " +i);
}
return true;
}
public static void main(String[] args) {
float x = 11f;
if (ehPrimo(x)) // se for primo
System.out.println(x + " e primo");
else // se não for primo
System.out.println(x + " não e primo");
}
}