I didn't understand why in this code that calculates the powers of 2, the e is decremented inside the while loop:
public class Power {
public static void main (String [] args) {
int e;
int result;
for (int i=0; i< 10; i++) {
result = 1;
e = i;
while (e > 0) {
result *= 2;
e--;
}
System.out.println("2 to the " + i + " power is " + result);
}
}
}
If I run without the e-- the code only executes the first one. It only works with the e--.
i?