Formula.java defines useful mathematical functions.
factorial() computes n!, given a nonnegative BigInteger.Receive: n, a BigInteger
Precondition: n >= 0
Return: n! = 1 * 2 * ... * (n-1) * n
summation(long n) computes the sum of the integers from 1 to n using Gauss' formula.Receive: n, a long
Precondition: n > 0
Return: the long value = 1 + 2 + ... + n
Back to the package documentation index