SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.number.big
Class BigIntegerUtils

java.lang.Object
  extended by com.numericalmethod.suanshu.number.big.BigIntegerUtils

public class BigIntegerUtils
extends java.lang.Object

This class collects a set of utility functions for the java class BigInteger.

See Also:
Class BigInteger

Method Summary
static java.math.BigInteger combination(int n, int k)
          Compute the combination function/binomial coefficient.
static java.math.BigInteger factorial(int n)
          Compute the n factorial.
static java.math.BigInteger permutation(int n, int k)
          Compute the permutation function.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

factorial

public static java.math.BigInteger factorial(int n)
Compute the n factorial.

Parameters:
n - an integer
Returns:
n!
See Also:
Wikipedia: Factorial

combination

public static java.math.BigInteger combination(int n,
                                               int k)
Compute the combination function/binomial coefficient. It is the number of k-combinations (each of size k) from a set S with n elements (size n).

Parameters:
n - the size of the full set
k - the size of a combination
Returns:
n! / (n-k)! / k!
See Also:
Wikipedia: Combination

permutation

public static java.math.BigInteger permutation(int n,
                                               int k)
Compute the permutation function. It is the number of k-permutations (each of size k) from a set S with n elements (size n).

Parameters:
n - the size of the full set
k - the size of a permutation
Returns:
n! / (n-k)!
See Also:
Wikipedia: Permutation

SuanShu, a Java numerical and statistical library

Copyright © 2011 Numerical Method Inc. Ltd. All Rights Reserved.