
Instead of using break statement in finding the prime nos ,is there any other way ?? if it is there pls tell that also

import java.io.*;
class FindPrimeWithoutBreak
{
public static void main(String[] args) {
for (int number = 2; number <= 100; number++) {
int maxFactor = (int)Math.sqrt(number);
boolean isPrime = true;
int factor = 2;
while (isPrime && factor <= maxFactor) {
if (number % factor == 0) {
isPrime = false;
}
factor++;
}
if (isPrime) System.out.println(number);
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.