TITLE: Count number of increasing functions, nondecreasing functions $f: \{1, 2, 3, \ldots, n\} \to \{1, 2, 3, \ldots, m\}$, with $m \geq n$.
QUESTION [16 upvotes]: I stumbled upon a question given like:
Let $m$ and $n$ be two integers such that $m \geq n \geq 1$. 
Count the number of functions $$f: \{1, 2, · · · , n\} \to \{1, 2, · · · , m\}$$ of the following two types:
(a) strictly increasing; i.e., whenever $x < y, f(x) < f(y)$, and
(b) non-decreasing; i.e., whenever $x < y, f(x) \leq f(y)$.
I tried in the following way.
For (a). We can say $f(n)>f(n-1)$ AND $f(n)>f(n-2) \ldots f(n)>f(1)$ (total $n-1$ elements)
Similarly for $f(n-1)>f(n-2), f(n-1)>f(n-3) \ldots f(n-1)>f(1)$ (total $n-2$ elements)...
and $f(2)>1$
Like this $$(n-1) + (n-2) + \ldots + (1) = \frac{n(n-1)}{2}$$
Is this correct?
For (b). Since there's equality, it will be $$n + (n-1) + ... (1) = \frac{n(n+1)}{2}$$
Is my approach correct? Any help is appreciated. Thanks in advance.

REPLY [2 votes]: A different approach for the non-decreasing case.
Set $F(n,m) = |\{ f : \{1, \ldots, n\} \to \{1,\ldots,m\} \mid f \mbox{ is non-decreasing. } \}|$. Then, $F(n,1) = 1$. Furthermore, we have the following recurrence relation:
$$
 F(n,m) = \sum_{i=0}^n F(n - i, m - 1). \quad (*)
$$
Proof. If $f : \{1,\ldots,n\} \to \{1,\ldots,m\}$ is non-decreasing,
set $k = |f^{-1}(1)|$.
Then, $f^{-1}(1) = \{1,\ldots, k \}$ (possibly empty)
and $f$ restricted to $\{ k + 1, \ldots, n \}$ (also possibly empty)
could be seen as a non-decreasing function from $\{k+1,\ldots,n\}$ to $\{2,\ldots,m-1\}$. For the restriction, we have $F(n - k, m - 1)$ many possibilities (the concrete naming of the numbers does not matter, just that they form a consecutive order) and each possibility is determined uniquely. Conversely, from any non-decreasing function $g : \{1,\ldots,n\}\to \{1,\ldots,m\}$ and $0 \le k \le n$ we can uniquely construct a non-decreasing function $f : \{1,\ldots,n+k\} \to \{1,\ldots, m+1\}$ by setting
$$
 f(x) = \left\{
\begin{array}{ll}
 1        & 1 \le x \le k \\
 g(x) + 1 & \mbox{otherwise.}
\end{array}
\right.
$$
So, we have shown the recurrence equation. QED
Now, for the binomial coefficient, the following formula is valid:
$$
 \binom{m}{m} + \binom{m + 1}{m} + \binom{m + 2}{m} + \ldots + \binom{m + n}{m} = \binom{n + m + 1}{m+1},
$$
which is easy to prove by induction. Setting
$$
 G(n,m) = \binom{n + m - 1}{m-1},
$$
we see that $G$ fulfills Equation (*) above, and $G(n,1) = 1$. Hence, inductively, $F(n,m) = G(n,m)$.
A concrete example. Let $a < b < c$, then, non-decreaasing functions with codomain of size three could be interpreted as ordered strings over $\{a,b,c\}$. Then, for the domain of size three, we have the strings
$$
 aaa, aab, aac, abb, abc, acc, 
 bbb, bbc, bcc, ccc.
$$
I hope it could be seen how to construct these strings out of the ordered strings over $\{b,c\}$ of length at most three by appending runs of $a$'s in front of them.