code: public static BigInteger bigFactorial(int n)
      {
          if (n < 0)
          {
              throw new IllegalArgumentException("Argument must greater than or equal to zero.");
          }
  
          BigInteger factorial = null;
          if (n < CACHE_SIZE) // Check for a cached value.
          {
              factorial = BIG_FACTORIALS.get(n);
          }
  
          if (factorial == null)
          {
              factorial = BigInteger.ONE;
              for (int i = n; i > 1; i--)
              {
                  factorial = factorial.multiply(BigInteger.valueOf(i));
              }
              if (n < CACHE_SIZE) // Cache value.
              {
                  BIG_FACTORIALS.putIfAbsent(n, factorial);
              }
          }
  
          return factorial;
      }
docs: Calculates the factorial of n where n is a positive integer.
  Zero factorial is equal to 1.  For values of n up to 20, consider
  using {@link #factorial(int)} instead since it uses a faster
  implementation.
  @param n The factorial to calculate.
  @return The factorial of n.
  @see #factorial(int)