Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Hands on the CombinatoricsUtils Class in Apache Commons Math

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Loading...
Loading...
import org.apache.commons.math3.util.CombinatoricsUtils._

binomialCoefficient

10
10.0
2.302585092994046

combinationsIterator

Notice that this methods returns an iterator of the type java.util.Iterator[Array[Int]], which is not a Scala Iterator! For combinations/permutations iterator, it is suggested that you use Seq.combinations and/or Seq.permutations.

org.apache.commons.math3.util.Combinations$LexicographicIterator@1ab48026

Factorial

3628800
org.apache.commons.math3.exception.MathArithmeticException: arithmetic exception
  at org.apache.commons.math3.util.CombinatoricsUtils.factorial(CombinatoricsUtils.java:281)
  ... 46 elided
9.332621544395286E157
2.43290200817664E18
363.7393755555636

Stirling

9330