This Python program reads a number from the user and performs a countdown from that number to 1 using recursion.
Each step prints the current number until it reaches 1.
This exercise is ideal for practicing recursive function design and base-case logic.
def recursive_countdown(n):
if n < 1:
return
print(n)
recursive_countdown(n - 1)
# Run the program
number = int(input("Enter a number to start countdown: "))
recursive_countdown(number)
5
4
3
2
1
- The program reads a number from the user
- It calls the recursive_countdown function with that number
- The function prints the number, then calls itself with n - 1
- The recursion stops when n becomes less than 1
- The result is a clean countdown from the input number to 1