public class FactorialIter { public static int factorial(int n) { if (n<0) { throw new IllegalArgumentException(Integer.toString(n)); } int result = 1; while (n > 1) { result = result * n; // n = n - 1; } return result; } public static void main(String[] args) { System.out.println(factorial(10)); } } // > java FactorialIter