Python Program to Print First N Numbers in Reverse using Recursion

Python Program to Print First N Numbers in Reverse using Recursion

Write Python Program to Print First N Numbers in Reverse using Recursion

# Write Python Program to Print First N Numbers in Reverse using Recursion

def print_numbers(n):
    if n == 1:
        print(n, end = ' ')
    else:        
        print(n, end = ' ')
        print_numbers(n - 1)        

n = 10
print(f'First {n} Numbers in Reverse: ')
print_numbers(n)

Output:

First 10 Numbers in Reverse: 
10 9 8 7 6 5 4 3 2 1