So I'm learning Java by myself and I would like to create a program that returns the divisors of a number N in a given interval [A, B]. Here's my code
Scanner in = new Scanner(System.in);
int n, a, b;
System.out.print("A: ");
a = in.nextInt();
System.out.print("B: ");
b = in.nextInt();
System.out.print("N: ");
n = in.nextInt();
System.out.printf("The divisors of %d in the interval [%d, %d] are: ", n, a, b);
for (int i = 1; i <= n & i < b; ++i){
if (n % i == 0){
System.out.println(i + " ");
}
}
Here's the problem: when I put a < i & i < b in the for condition, the program doesn't work. I've read it that Java is short-circuiting, but can I fix my code or should I use a while or something like that?