JNumberTools is an open-source Java library designed to provide powerful tools for solving complex problems in combinatorics and number theory.
JNumberTools allows you to tackle challenging combinatorics problems—such as permutations, combinations, conditional-cartesian-products, ranking, partitions, etc. for both academic and practical applications in fields like mathematics, cryptography, data analysis, number theory, and algorithm design.
Key Features:
- Versatile and efficient APIs for various combinatorics and number-theory operations.
- Ideal for educational, research, and real-world problem-solving in cryptography, computer science, puzzle-creation, and optimization.
- Optimized for both small-scale and large-scale problems, delivering high performance.
The latest release of the library is v3.0.0.
It is available through The Maven Central Repository here.
Add the following section to your pom.xml
file.
<dependency>
<groupId>io.github.deepeshpatel</groupId>
<artifactId>jnumbertools</artifactId>
<version>3.0.0</version>
</dependency>
Currently Available Algorithms
-
Ranking of permutations & combinations
- Ranking of unique permutation
- Ranking of k-permutation
- Ranking of repetitive permutation
- Ranking of unique combination
- Rank of repetitive combination : Coming soon
- Rank of multiset permutation : Coming soon
- Rank of multiset combination : Coming soon
-
Number system algorithms related to combinatorics
- Factorial Number System aka Factoradic
- Permutation Number System aka Permutadic
- Combinatorial Number System aka Combinadic
Calculates the rank of a unique permutation starting from 0th For example, there are total 4!=24 permutations of [0,1,2,3] where the first permutation [0,1,2,3] has rank 0 and the last permutation [3,2,1,0] has the rank of 23
BigInteger rank = JNumberTools.rankOf().uniquePermutation(3,2,1,0);
Calculates the rank of a k=permutation. For example if we select 5 elements out of 8 [0,1,2,3,4,5,6,7] then there are total 8C5 permutations out of which 1000th permutation is [8,4,6,2,0]
//will return 1000
BigInteger rank = JNumberTools.rankOf().kPermutation(8,4,6,2,0);
Calculates the rank of repetitive permutation of
//1,0,0,1 is the 9th repeated permutation of two digits 0 and 1
int elementCount = 2;
BigInteger result = JNumberTools.rankOf()
.repeatedPermutation(elementCount, new Integer[]{1,0,0,1});
Calculates the rank of given combination. For example if we generate combination of 4 elements out of 8 in lex order, then 35th combination will be [1,2,3,4]. So given the input 8 and [1,2,3,4], the API returns 35, the rank of combination
BigInteger rank = JNumberTools.rankOf().uniqueCombination(8, 1,2,3,4);