import java.math.*;

// A first version of the factorial function that
// takes an int as parameter
BigInteger fact(int n) {
    // A forward reference to fact(BigInteger n)
    return fact(new BigInteger("" + n));
}

// An overloaded recursive version of the factorial
// function that takes a BigInteger as parameter
BigInteger fact(BigInteger n) {
    return (n.equals(BigInteger.ZERO)) ?
        BigInteger.ONE : n.multiply(fact(n.subtract(BigInteger.ONE)));
}

System.out.println("fact(30) = " + fact(30));
