This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
 Documentation / Mathematica / Add-ons / Standard Packages / DiscreteMath  /

DiscreteMath`CombinatorialFunctions`

This package defines the functions CatalanNumber, Hofstadter and Subfactorial that are used in combinatorial analysis. Several related functions, such as Factorial, Factorial2, Binomial, Multinomial, Pochhammer, and Fibonacci are normally available in Mathematica without loading this package.


Combinatorial functions.

The Catalan numbers, which appear in various tree enumeration problems, are given in terms of binomial coefficients according to
.
Hofstadter's function
is defined recursively for positive integers by and
.
Subfactorial[
n] is given by

.

  • This loads the package.
  • In[1]:= <<DiscreteMath`CombinatorialFunctions`

  • This is the number of permutations of four objects that leaves none of the objects unchanged.
  • In[2]:= Subfactorial[4]

    Out[2]=

  • This plot demonstrates the chaotic behavior of Hofstadter's function, described in the book Gödel, Escher, Bach: An Eternal Golden Braid.
  • In[3]:= ListPlot[Table[Hofstadter[n], {n, 1000}]]