| 
            
             Be the first user to complete this post  
            
             | 
         Add to List | 
308. Print Numbers from 1 to N without using loop
Objective: Given a number N, write an program to print from number 1 to N without using loop.
Example:
N = 20 Output: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Approach: Use Recursion
- Make recursive to N = N-1.
 - In tail recursion, print the number
 
Code:
Output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20