Combinatorial Functions

Factorial(n) : RngIntElt -> RngIntElt
The factorial n! for non-negative small integer n.
NumberOfPermutations(n, k) : RngIntElt, RngIntElt -> RngIntElt
The number of permutations of n distinct objects taken k at a time.
Binomial(n, r) : RngIntElt, RngIntElt -> RngIntElt
The binomial coefficient n choose r.
Multinomial(n, [r1, ... rn]) : RngIntElt, [RngIntElt] -> RngIntElt
Given a sequence Q = [r1, ..., rk] of positive integers such that n = r1 + ... + rk, return the multinomial coefficient n choose r1, ..., rk.
Fibonacci(n) : RngIntElt -> RngIntElt
Given an integer n, this function returns the n-th Fibonacci number Fn, which can be defined via the recursion F0 = 0, F1 = 1, Fn = Fn - 1 + Fn - 2 for all integers n. Note that n is allowed to be negative, and that F - n = ( - 1)n + 1 Fn.
Catalan(n) : RngIntElt -> RngIntElt
Given a small non-negative integer n, this function returns the n-th Catalan number Cn, defined via the recursion C0 = 1, Cn + 1 = Cn.(4n + 2)/(n + 2).
Lucas(n) : RngIntElt -> RngIntElt
Given an integer n, this function returns the n-th Lucas number Ln, which can be defined via the recursion L0 = 2, L1 = 1, Ln = Ln - 1 + Ln - 2 for all integers n. Note that n is allowed to be negative, and that L - n = ( - 1)nLn.
GeneralizedFibonacciNumber(g0, g1, n) : RngIntElt, RngIntElt, RngIntElt -> RngIntElt
The nth member of the generalized Fibonacci sequence defined by G0 = g0, G1 = g1, Gn = Gn - 1 + Gn - 2 for all integers n. Note that n is allowed to be negative. The Fibonacci and Lucas numbers are special cases where (g0, g1) = (0, 1) or (2, 1) respectively.
StirlingFirst(n, k) : RngIntElt, RngIntElt -> RngIntElt
The Stirling number of the first type, [(n atop k)], where n and k are non-negative integers.
StirlingSecond(n, k) : RngIntElt, RngIntElt -> RngIntElt
The Stirling number of the second type, {(n atop k)}, where n and k are non-negative integers.
Bell(n) : RngIntElt -> RngIntElt
The nth Bell number, giving the number of partitions of a set of size n. (Not to be confused with NumberOfPartitions(n), which gives the number of partitions of the integer n.) This is equal to the sum of StirlingSecond(n,k) for k between 0 and n (inclusive).
EulerianNumber(n, r) : RngIntElt, RngIntElt -> RngIntElt
The number E(n, r) of permutations p of {1, ..., n} having exactly r ascents (i.e., places where pi < pi + 1)
HarmonicNumber(n) : RngIntElt -> FldRatElt
The nth harmonic number Hn = Σi=1n (1/i).
BernoulliNumber(n) : RngIntElt -> FldRatElt
Returns the nth Bernoulli number Bn as a rational number.
BernoulliApproximation(n) : RngIntElt -> FldPrElt
Returns a real approximation to the nth Bernoulli number Bn.
BernoulliPolynomial(n) : RngIntElt -> RngUPolElt
The nth Bernoulli polynomial Bn(x) = ∑k=0n (n choose k) Bk xn - k where Bn is the nth Bernoulli number.
V2.28, 13 July 2023