How many nondecreasing functions $f:\{1,2, \ldots, n\} \to \{1,2, \ldots, n\}$ with $f(i)\leq i$ are there?

Solution 1:

These are just the Catalan numbers. Plot points in the $n\times n$ grid, with coordinates $(i, f(i))$. Then connect the bottom-left corner to the upper-right corner by going through the points (and never going above the diagonal).

enter image description here

In this picture, the yellow line represents the function: $$ f(1) = 1, f(2) = 1, f(3) = 2 $$ and the blue line represents the function $$ f(1) = 1, f(2) = 2, f(3) = 2 $$

[Green is where they overlap.]

The Catalan numbers count the number of paths below the diagonal. And the points you've plotted uniquely identify such a path.