ann.math.Formula

 

Formula.java defines useful mathematical functions.

 

public static BigInteger factorial(BigInteger n)

factorial() computes n!, given a nonnegative BigInteger.

Receive: n, a BigInteger

Precondition: n >= 0

Return: n! = 1 * 2 * ... * (n-1) * n

 

public static long summation(long 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


Back to the Introduction


Copyright 2000 by Prentice Hall. All rights reserved.