previous |
start |
next
Simple Application: compute factorial
public class Factorial {
public static void main(String[] args) {
int f = 1;
int n = Integer.parseInt(args[0]);
while (n > 1) {
f = f * n;
n--;
}
System.out.println(args[0] + "! = " + f);
}
}
previous |
start |
next