Here you can find the source of product(final BigInteger min, final BigInteger max)
Parameter | Description |
---|---|
min | First number to include in product |
max | Last number to include in product |
public static BigInteger product(final BigInteger min, final BigInteger max)
//package com.java2s; //License from project: Open Source License import java.math.BigInteger; public class Main { /**/* w w w .j a va 2s .c o m*/ * Compute the product of all integers in the range [min,max]. * @param min First number to include in product * @param max Last number to include in product * @return Product of all integers in range. */ public static BigInteger product(final BigInteger min, final BigInteger max) { BigInteger ret = BigInteger.ONE; for (BigInteger i = min; i.compareTo(max) <= 0; i = i.add(BigInteger.ONE)) { ret = ret.multiply(i); } return ret; } /** * Compute the product of all integers in the range [min,max]. * @param min First number to include in product * @param max Last number to include in product * @return Product of all integers in range. */ public static long product(final long min, final long max) { long ret = 1; for (long i = min; i <= max; ++i) { ret *= i; } return ret; } }