直接上代码
public class IsPrimeNumber {
public boolean isPrime(long num) {
for (int j = 2; j <= Math.sqrt(num); j++) {
if (num % j == 0) {
return false;
}
}
return true;
}
public static void main(String[] args) {
for (int i = 2; i < 100; i++) {
if (new IsPrimeNumber().isPrime(i))
System.out.println(i);
}
}
}