A combinatorics library for Julia, focusing mostly (as of now) on enumerative
combinatorics and permutations. As overflows are expected even for low values,
most of the functions always return BigInt
, and are marked as such below.
This library provides the following functions:
bellnum(n)
: returns the n-th Bell number; always returns aBigInt
;catalannum(n)
: returns the n-th Catalan number; always returns aBigInt
;lobbnum(m,n)
: returns the generalised Catalan number atm
andn
; always returns aBigInt
;narayana(n,k)
: returns the general Narayana number at any givenn
andk
; always returns aBigInt
;combinations(a,n)
: returns all combinations ofn
elements of indexable objecta
;combinations(a)
: returns combinations of all order by chaining calls tocombinations(a,n)
;derangement(n)
/subfactorial(n)
: returns the number of permutations of n with no fixed points; always returns aBigInt
;partialderangement(n, k)
: returns the number of permutations of n with exactly k fixed points; always returns aBigInt
;doublefactorial(n)
: returns the double factorial n!!; always returns aBigInt
;fibonaccinum(n)
: the n-th Fibonacci number; always returns aBigInt
;hyperfactorial(n)
: the n-th hyperfactorial, i.e. prod([i^i for i = 2:n]; always returns aBigInt
;integer_partitions(n)
: returns aVector{Int}
consisting of the partitions of the numbern
.jacobisymbol(a,b)
: returns the Jacobi symbol (a/b);lassallenum(n)
: returns the nth Lassalle number An defined in arXiv:1009.4225 (OEIS A180874); always returns aBigInt
;legendresymbol(a,p)
: returns the Legendre symbol (a/p);lucasnum(n)
: the n-th Lucas number; always returns aBigInt
;multifactorial(n)
: returns the m-multifactorial n(!^m); always returns aBigInt
;multinomial(k...)
: receives a tuple ofk_1, ..., k_n
and calculates the multinomial coefficient(n k)
, wheren = sum(k)
; returns aBigInt
only if given aBigInt
;multiexponents(m,n)
: returns the exponents in the multinomial expansion (x₁ + x₂ + ... + xₘ)ⁿ;primorial(n)
: returns the product of all positive prime numbers <= n; always returns aBigInt
;stirlings1(n, k, signed=false)
: returns the(n,k)
-th Stirling number of the first kind; the number is signed ifsigned
is true; returns aBigInt
only if given aBigInt
.stirlings2(n, k)
: returns the(n,k)
-th Stirling number of the second kind; returns aBigInt
only if given aBigInt
.nthperm(a, k)
: Compute thek
th lexicographic permutation of the vectora
.permutations(a)
: Generate all permutations of an indexable objecta
in lexicographic order.
Limited support for working with Young diagrams is provided.
partitionsequence(a)
: computes partition sequence for an integer partitiona
x = a \ b
creates the skew diagram for partitions (tuples)a
,b
isrimhook(x)
: checks if skew diagramx
is a rim hookleglength(x)
: computes leg length of rim hookx
character(a, b)
: computes character the partitionb
in thea
th irrep of Sn