/** Compute the factorial of a number taken from the command line * * @author ggtowell * Created: Oct 2023 */ public class Factorial { public static void main(String[] args) { int numFromUser = 0; try { numFromUser = Integer.parseInt(args[0]); int factResult = doFactorial(numFromUser); System.out.println("The factorial of " + numFromUser + " is " + factResult); System.out.println("The factorial of " + numFromUser + " is " + doFactorial(numFromUser)); } catch (Exception error) { System.out.println(error); return; } } public static int doFactorial(int highest) { int rtn = 1; for (int i = highest; i >= 1; i--) { rtn *= i; } return rtn; } }