# Mastering Recursion For Beginners-(Part 4)

*Continuing our recursion series, this problem statement will be divided into two parts: I and II.Part I: Using recursion, find all numbers from 1 to n-digits. If say n=2, then a number between 1 and 99 should be printed.*

*Before we begin, we must first learn how to create an n+1 digit number from a n digit integer.*

*Assume we have number=2 and want to convert it to a two-digit number. We must multiply by ten (2*10=20+adding all digits (0–9)). It’s simple, right?First, let us create our function.*

*Print all numbers from 1 to ((10^N)-1) using GenerateNdigits(N,number=0).Assume N=3. __a__|( b__ | c__ ).*

*Here, a, b, and c represent the ***hundredth***, ***tenth***, and ***unit’s*** position, respectively where a, b, and c can have values ranging from [0-9].Assume I obtain all of the numbers from ( __b__ |__ c__.) As a result, recursion will be used to complete this task.The only work which we need to do is to try all possible value of a from 0 to 9.*

*See the diagram below.*

*Essentially, we are supplying a starting digit (Leftmost Digit) and instructing recursion to generate all number when we place starting digit say d(0–9) (leap of faith), as well as multiplying the ***number*** state in with 10 to produce the next (N-1) digits.The code is as follows:*-

*Output(n==2):-*

*Next part II deals when we just dont want to print all n digits number but specific say n=123 , then printing all numbers from 1 to 123.*