When the program is finding the prime numbers, it compiles.
But an error occurred during runtime. How can I fix it ?
What is the easiest way of finding prime numbers?
Error :
Exception in thread "main" java.lang.ArithmeticException: / by zero
at PrimeNumbers.main(PrimeNumbers.java:6)
Code :
import java.util.*;
class PrimeNumbers {
public static void main(String args[]) {
for (int i = 0; i <= 100; i++) {
for (int j = 0; j < i; j++) {
if (i % j == 0) {
break;
} else {
System.out.println(i);
}
}
}
}
}