Returns {@code n!}, that is, the product of the first {@code n} positive integers, {@code 1} if
{@code n == 0}, or {@link Long#MAX_VALUE} if the result does not fit in a {@code long}.

@throws IllegalArgumentException if {@code n < 0}
16690
public static long factoriall(int n) {
        checkNonNegative("n", n);
        return (n < long_factorials.length) ? long_factorials[n] : Long.MAX_VALUE;
    }
1239534
@Override
  public Long max11(Long arg1, Long arg2) {
    if (arg1 == null || arg2 == null) {
      return null;
    } else {
      return Math.max(arg1, arg2);
    }
  }
1183670
public static int maxInArray(int[] values)
    {
        if ((values == null) || (values.length == 0))
        {
            throw new IllegalArgumentException("Cannot find the max of a null or empty array.");
        }

        int max = values[0];

        for (int value : values)
        {
            max = (max < value) ? value : max;
        }

        return max;
    }
542506
public static <T extends Comparable<? super T>> T max(T[] numberArray) {
		if (isEmpty(numberArray)) {
			throw new IllegalArgumentException("Number array must not empty !");
		}
		T max = numberArray[0];
		for (int i = 0; i < numberArray.length; i++) {
			if (ObjectUtil.compare(max, numberArray[i]) < 0) {
				max = numberArray[i];
			}
		}
		return max;
	}
988637
function factorial(n) {
  const start = n === 0 ? 1 : Math.abs(n)
  return start > MAX_FACTORIAL
    ? Infinity
    : _.chain(_.range(start, 1))
        .reduce((x, y) => x * y)
        .value()
}
12168
public static double binomial(int k, double p, int n) {
        if(k<0 ||  p<0 || n<1) {
            throw new IllegalArgumentException("All the parameters must be positive and n larger than 1.");
        }
        
        k = Math.min(k, n); 
        
        /*
        //Slow and can't handle large numbers
        $probability=StatsUtilities::combination($n,$k)*pow($p,$k)*pow(1-$p,$n-$k);
        */

        //fast and can handle large numbers
        //Cdf(k)-Cdf(k-1)
        double probability = approxBinomialCdf(k,p,n); 
        if(k>0) {
            probability -= approxBinomialCdf(k-1,p,n);
        }
        
        return probability;
    }
1358657
protected static long nCk(int n, int k)
    {
        if (k > n)
        {
            return 0;
        }
        long result = 1;
        for (int i = 1; i <= k; i++)
        {
            result *= n--;
            result /= i;
        }
        return result;
    }
587973
public static double negativeBinomial(int n, int r, double p) {
        //tested its validity with http://www.mathcelebrity.com/binomialneg.php
        if(n<0 || r<0 || p<0) {
            throw new IllegalArgumentException("All the parameters must be positive.");
        }
        n = Math.max(n,r);//obvisouly the total number of tries must be larger than the number of required successes
        
        double probability = Arithmetics.combination(n-1, r-1)*Math.pow(1-p,n-r)*Math.pow(p,r);
        
        return probability;
    }
1269042
public static double negativeBinomialCdf(int n, int r, double p) {
        if(n<0 || r<0 || p<0) {
            throw new IllegalArgumentException("All the parameters must be positive.");
        }
        n = Math.max(n,r);
        
        double probabilitySum = 0.0;
        for(int i=0;i<=r;++i) {
            probabilitySum += negativeBinomial(n, i, p);
        }
        
        return probabilitySum;
    }
1078923
public static int maxFill(int n, float f) {
		return Math.min((int) Math.ceil((double) ((float) n * f)), n - 1);
	}
1366700
private BigInteger bigIntegerProduct()
    {
        return this.injectInto(BigInteger.valueOf(1L), new Function2<BigInteger, Integer, BigInteger>()
        {
            public BigInteger value(BigInteger result, Integer each)
            {
                return result.multiply(BigInteger.valueOf(each.longValue()));
            }
        });
    }
468057
public long nextLong(final long n) 
        {
        if (n<=0)
            throw new IllegalArgumentException("n must be > 0");
        
        long bits, val;
        do 
            {
            bits = (nextLong() >>> 1);
            val = bits % n;
            } 
        while(bits - val + (n-1) < 0);
        return val;
        }
109295
public Object productElement(int n) {
        assert n >= 0 && n < 3;
        switch (n) {
            case 0: return dataType;
            case 1: return geographicalLocation;
            case 2: return isSecret;
            default: throw new IllegalArgumentException(n + " is not an allowed index into UserStub!");
        }
    }
303487
public static Number checkBetween(Number value, Number min, Number max) {
		notNull(value);
		notNull(min);
		notNull(max);
		double valueDouble = value.doubleValue();
		double minDouble = min.doubleValue();
		double maxDouble = max.doubleValue();
		if (valueDouble < minDouble || valueDouble > maxDouble) {
			throw new IllegalArgumentException(StrUtil.format("Length must be between {} and {}.", min, max));
		}
		return value;
	}
9215
int firstOneInRange(int from, int to) {
		if (from < 0) throw new IllegalArgumentException();
		if (to < from) throw new IllegalArgumentException();
		from += start;
		to += start;
		if (to > finish) throw new IllegalArgumentException();
		return firstOneInRangeAdj(from, to) - start;
	}
1183312
@ArgumentsChecked
	@Throws(IllegalNullArgumentException.class)
	public static int checkLong(@Nonnull final Number number) {
		Check.notNull(number, "number");
		if (!isInLongRange(number)) {
			throw new IllegalNumberRangeException(number.toString(), LONG_MIN, LONG_MAX);
		}

		return number.intValue();
	}
582143
public long getCurrentValue(int nth) {
    long v = min.getCurrent(nth).get();
    return (v == Long.MAX_VALUE) ? 0L : v;
  }