- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python Program to Print Numbers in a Range (1,upper) Without Using any Loops
When it is required to print the numbers in a given range without using any loop, a method is defined, that keeps displays numbers from higher range by uniformly decrementing it by one after every print statement.
Below is the demonstration of the same −
def print_nums(upper_num): if(upper_num>0): print_nums(upper_num-1) print(upper_num) upper_lim = 6 print("The upper limit is :") print(upper_lim) print("The numbers are :") print_nums(upper_lim)
The upper limit is : 6 The numbers are : 1 2 3 4 5 6
A method named ‘print_nums’ is defined.
It checks if the upper limit is greater than 0.
If so, keeps displaying the elements.
After every display, the upper range value is decremented by 1.
Outside the function, a value for upper limit is defined.
This method is called by passing the parameter.
The output is displayed on the console.
- Golang Program to Print the Numbers in a Range (1, upper) without Using any Loops
- Program to print numbers from 1 to 100 without using loop
- C Program to print numbers from 1 to N without using semicolon
- Print Number series without using any loop in Python Program
- Python Program for Print Number series without using any loop
- Python program to print all even numbers in a range
- Python program to print all odd numbers in a range
- Java Program to print Number series without using any loop
- C program to print number series without using any loop
- Print a pattern without using any loop in C++
- Program to print prime numbers in a given range using C++ STL
- C program to print a string without any quote in the program
- Print m multiplies of n without using any loop in Python.
- How will you print numbers from 1 to 100 without using loop in C?
- Python Program to Print all Numbers in a Range Divisible by a Given Number