/** FactorialFinder.java performs the factorial function.
 *  @author Joel Adams
 *
 */

import java.util.Scanner;
import java.math.BigInteger;

public class FactorialFinder {
    public static long factorial1(int n) {
	if (n > 1) {
		return factorial1(n-1) * n;
	} else {
		return 1;
	}
    }

    public static BigInteger factorial2(int n) {
	if (n > 1) {
		BigInteger bigN = BigInteger.valueOf(n);
		return factorial2(n-1).multiply(bigN);
	} else {
		return BigInteger.ONE;
	}
    }

    public static void main(String [] args) {
	System.out.print("To compute n!, enter n: ");
	Scanner keyboard = new Scanner(System.in);
	int n = keyboard.nextInt();
	System.out.printf("%d! == %d%n", n, factorial1(n) );
	System.out.printf("%d! == %d%n", n, factorial2(n) );
    }
}

