Looking for all numbers where each digit is bigger than the previous digit This is the "Increasing Number problem", where we are looking for all numbers with \$n\$ digits where each digit is bigger than the digit before it. Or in Mathematical therms where: 

$$\mathit{IncreasingNumber} = c_n \times 10^n + c_{n-1} \times 10^{n-1} + \cdots + c_1 * 10 + c_0$$

and \$c_i &lt; c_{i-1}\$.

Examples: 123456789 or 123 or 569 or 139 or 45 or 12379. Goal: Give out all numbers that fullfill these properties depending on the number of digits \$n\$. This is my brute force code: 

Sub AllIncreasingNumbers(N As Integer)
Dim Number As Long
Dim i As Long
Dim j As Integer
Dim lastdig As Integer
Dim remainder As Long
Dim thisdig As Integer



For i = (1 * 10 ^ (N - 1)) To 10 ^ (N)
    remainder = i
    lastdig = 0
    For j = (N - 1) To 0 Step -1
        thisdig = (remainder \ (10 ^ j))
        If Not (lastdig &lt; thisdig) Then
        GoTo NotPass
        End If
        lastdig = thisdig
        remainder = remainder Mod (10 ^ j)
    Next j
    Debug.Print i
NotPass:
Next i
End Sub


If you haven't guessed it, it functions as following: go through all Numbers with N digits and check if they are increasing Numbers, if yes print them.

For \$n\$ = 2 to 6 it is reasonably fast but for \$n\$ = 8 or 9 it is really slow despite \$n=9\$ only having one solution 123456789. I think there could be a recursive algorithm to solve this but I can't figure it out. I used VBA because thats the language I am most familiar with but actually I am more intrested in the recursive algorithm to solve this. As soon as I have the algorithm I am able to implement it.
Instead of searching all numbers and checking them one by one, why not construct the numbers from the rule. In other words, start with the smallest digit being 1, then the next digit being 2 and so on. The digits can then be increased right to left as long as the rule holds.

For example, finding all 8 digit numbers:

Start with each digit increasing by 1 left to right:


12345678


Add one to the final digit:


12345679


Run out of digits so increase the digit to the left:


12345689
12345789
12346789 
...
23456789


EDIT for further explanation:

For smaller numbers, you then need to repeat this process recursively. For example:


123 -> 124 -> 125 ... 129


You would now need to "reset" the second digit and any following it to one above what it was:


129 -> 134 -> 135 -> 136 ... 139
139 -> 145 -> 146 -> 147 ... 149
149 -> 156 -> 157 -> 158 -> 159


And so on.

You are still effectively working backwards through the digits, recursively increasing them right to left.

Hope that helps.