[Solved] My Question is about the prime number code that it display multiple of three


Try this inside the loop with j as counter variable. This ensures that all the numbers from 2 to j-1 are not factors of j. Also check on other methods of prime number generation like Sieve of Eratosthenes, or reducing the complexity of this code by running loop till sqrt(j)

counter=0;
for(i=2;i<j;i++){
    if(j%i==0){
        counter=1;
        break;
    }
}
if(counter==0){
    System.out.println(j);
}

solved My Question is about the prime number code that it display multiple of three