factorial method library in java

Solutions on MaxInterview for factorial method library in java by the best coders in the world

showing results for - "factorial method library in java"
Alistair
30 Jan 2018
12.4. Factorial Using Apache Commons Math
2Apache Commons Math has a CombinatoricsUtils class with a static factorial method that we can use to calculate the factorial.
3
4To include Apache Commons Math, we'll add the commons-math3 dependency into our pom:
5
6<dependency>
7    <groupId>org.apache.commons</groupId>
8    <artifactId>commons-math3</artifactId>
9    <version>3.6.1</version>
10</dependency>
11Let's see an example using the CombinatoricsUtils class:
12
13public long factorialUsingApacheCommons(int n) {
14    return CombinatoricsUtils.factorial(n);
15}