Class TriangularNumbers
- java.lang.Object
-
- ai.timefold.solver.core.impl.heuristic.selector.list.TriangularNumbers
-
public final class TriangularNumbers extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intnthTriangle(int n)Calculate nth triangular number.
-
-
-
Method Detail
-
nthTriangle
public static int nthTriangle(int n) throws ArithmeticExceptionCalculate nth triangular number. This is used to calculate the number of subLists for a given list variable of size n. To be able to useintarithmetic to calculate the triangular number, n must be less than or equal toHIGHEST_SAFE_N. If the n is higher, the method throws an exception.- Parameters:
n- size of the triangle (the length of its side)- Returns:
- nth triangular number
- Throws:
ArithmeticException- ifnis higher thanHIGHEST_SAFE_N
-
-