# Total number of non-decreasing numbers with n digits

**How many non-decreasing numbers can be generated of n digit length?**

**Example:**

Non-decreasing number means the digits from left to right will be in ascending order

123 is non-decreasing
213 is not
Say
n=1
So non-decreasing numbers will be all the single digit numbers
0
1
2
3
4
5
6
7
8
9
Total number of non-decreasing numbers of 1 digit=10
Now, if n=2
Non-decreasing numbers will be
00
01
02
03
04
05
06
07
08
09
11
12
13
..
So on,
**Note:** numbers with leading 0 is also counted
10 is not included in the list
For n=2
**Total number of non-decreasing numbers is 55**
(List all yourself if you have doubt!)

We will solve this problem with the help of combinatorics

Let's first see, how we can build up the generating function.

C++ implementation

need an explanation for this answer? contact us directly to get an explanation for this answerOutput