/* File: FacIt.java - March 2011 */ package l04; /** * Compute and display the factorial of the input argument * using an iterative algorithm * * Sample usage: java l04.FacIt 5 * * @author Michael Albert * */ public class FacIt{ public static void main(String[] args) { int n = Integer.parseInt(args[0]); System.out.println(n + "! = " + factorial(n)); } public static long factorial(int n) { long fac = 1; for(int i = 1; i <= n; i++) fac *= i; return fac; } }