Routines for combinatorics.