Finding prime numbers between two numbers
Hello everyone, I understood nearly everything except the part: " for(int j=2; j<=(i/2)+1; j++) " 2 is the lowest prime number; that's why we used j=2. But I couldn't understand where this one came from, like what bases they took to create this line: "j<=(i/2)+1". Can someone please explain it to me? Thank you in advance! Here is the full code: ----------------------------------------------------------------------- public class Codes { public static void main(String[] args) { int a = 21; int b = 90; for (int i = a; i < b; i++) { boolean asal=true; for(int j=2;j<=(i/2)+1;j++) if(i%j==0) { asal=false; break; } if(asal) System.out.println(i+"\t"); } }} -----------------------------------------------------------------------