package PrimeNum;
public class primeNum {
public static void main(String args[]){
int flag = 0;
/*
for(int i = 2; i <= 100; i++){
if(i % 2 != 0 && i % 3 != 0 && i % 4 != 0 && i % 5 != 0 &&
i % 6 != 0 && i % 7 != 0 && i % 8 != 0 && i % 9 != 0 && i % 10 != 0 ){
System.out.print(i + " ");
}
}
*/
System.out.println();
for(int i = 2; i <= 100; i++){
for(int j = 2; j <= 10; j++){
if(i % j != 0) {
flag++;
}
}
if(flag == 9 || flag == 8){
System.out.print(i + " ");
flag = 0;
}
}
}
}
The code is made using Java and I can't seem to find why it only prints 2 and 3 all throughout the loop to 100. Any Help please?