prime number from 1 to 100 in java code example
Example: java prime numbers from 1 to 100
public class Main {
public static void main(String[] args) {
for (int i = 2; i < 100; ++i) {
boolean isPrime = true;
int sqrt = (int)Math.ceil(Math.sqrt(i));
for (int divisor = 2; divisor <= sqrt; ++divisor) {
if (i % divisor == 0) {
isPrime = false;
break;
}
}
if (isPrime) {
System.out.println(i);
}
}
}
}