[Solved] issue in loop of finding prime number in java [closed]


First you need to understand the mathematics behind it. Any number (that is a whole number, without a fraction part like for example 1.5) will give the reminder 0 when divided by one:

n % 1 == 0

This condition will therefore always be true.
If your case, once you are at n = 1, you return false.
I suggest you print out the output at every line of your program, and you will see the behavior.

1

solved issue in loop of finding prime number in java [closed]