import java.util.Scanner; class Fact { /* this function returns the factorial * of the parameter that is passed in */ public static int fact(int x) { int f = 1; for (int i = x; i >= 0; i--) { f *= i; } return f; } /* main function to test out the factorial function above */ public static void main(String args[]) { System.out.printf("Enter a number: "); Scanner in = new Scanner(System.in); int number = in.nextInt( ); System.out.printf("%d! = %d\n", number, fact(number)); } }