I got this code from Beginning
Java 2 JDK 1.2.
public class Factorial {
public static void main(
String[] args){
long limit = 20;
long factorial = 1;
for(int i=1; i <= limit; i++){
factorial = 1;
for(int factor = 2; factor <= i; factor++){
factorial *= factor++;
System.out.println(i + " ! " + " is " + factorial );
}
}
}
I get the first part of the "For" loop but when it hits the second "For" loop. I see the loop_condition "factor <= i" never being true. Is the first time through the loop factor = 2 and i = 1. If so, isn't it false. I have changed the relational operation, <=, to different ones to see what would happen. Turns out, only <= works. Help!
------------------