code: public static BigInteger factorial(BigInteger value) {
      Assert.notNull(value, "value must not be null");
      Assert.isTrue(value.compareTo(BigInteger.ZERO) >= 0, String.format(NUMBER_LESS_THAN_ZERO_ERROR_MESSAGE, value));
  
      if (value.compareTo(TWO) <= 0) {
        return (value.equals(TWO) ? TWO : BigInteger.ONE);
      }
  
      BigInteger result = value;
  
      for (value = result.add(NEGATIVE_ONE) ; value.compareTo(BigInteger.ONE) > 0; value = value.add(NEGATIVE_ONE)) {
        result = result.multiply(value);
      }
  
      return result;
    }
docs: Calculates the factorial of the given number using an iterative algorithm and BigInteger value type
  to avoid a StackOverflowException and numeric overflow, respectively.
  
  @param value an Integer value used to compute the factorial.
  @return the factorial of the given number.
  @throws java.lang.IllegalArgumentException if the number value is null or less than 0.
  @see java.math.BigInteger