code: public static BigInteger factorial(BigInteger n) {
      BigInteger nFac = BigInteger.ONE;
      while(n.compareTo(BigInteger.ONE) > 0) {
        nFac = nFac.multiply(n);
        n = n.subtract(BigInteger.ONE);
      }
      return nFac;
    }
docs: Compute the Factorial of n, often written as <code>c!</code> in
  mathematics.
  <p>
  Use this method if for large values of <code>n</code>.
  
  @param n Note: n &gt;= 0. This {@link BigInteger} <code>n</code> will be 0
  after this method finishes.
  @return n * (n-1) * (n-2) * ... * 1