- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

In this tutorial, we are going to write a program to find out m multiples of a number n without using loops. For example, we have a number **n = 4** and **m = 3**, the output should be **4, 8, 12**. Three multiples of four. Here, the main constraint is not to use loops.

We can use the **range()** function to get the desired output without loops. What is the work of the range() function? **range()** function returns a range object which we can convert into an iterator.

Let's see the syntax of **range()**.

range(start, end, step)

start - starting number to the range of numbers end - ending number to the range of numbers (end number is not included in the range) step - the difference between two adjacent numbers in the range (it's optional if we don't mention then, it takes it as 1) range(1, 10, 2) --> 1, 3, 5, 7, 9 range(1, 10) --> 1, 2, 3, 4, 5, 6, 7, 8, 9

## working with range() ## start = 2, end = 10, step = 2 -> 2, 4, 6, 8 evens = range(2, 10, 2) ## converting the range object to list print(list(evens)) ## start = 1, end = 10, no_step -> 1, 2, 3, 4, 5, 6, 7, 8, 9 nums = range(1, 10) ## converting the range object to list print(list(nums))

If you run the above program, you will get the following results.

[2, 4, 6, 8] [1, 2, 3, 4, 5, 6, 7, 8, 9]

Now, we will write our code to the program. Let's see the steps first.

Now, we will write our code to the program. Let's see the steps first.

1. Initialize n and m. 2. Write a range() function such that it returns multiples of n. 3. Just modify the step from the above program to n and ending number to (n * m) + 1 starting with n.

See the code below.

## initializing n and m n = 4 m = 5 ## writing range() function which returns multiples of n multiples = range(n, (n * m) + 1, n) ## converting the range object to list print(list(multiples))

If you run the above program, you will get the following results.

[4, 8, 12, 16, 20]

I hope you enjoyed the tutorial, if you have any doubts regarding the tutorial, mention them in the comment section.

- Related Questions & Answers
- Print m multiplies of n without using any loop in Python.
- Print first m multiples of n in C#
- Print Number series without using any loop in Python Program
- Python Program for Print Number series without using any loop
- Print a pattern without using any loop in C++
- Java Program to print Number series without using any loop
- C program to print number series without using any loop
- Print a character n times without using loop, recursion or goto in C++
- Print first n distinct permutations of string using itertools in Python
- Constructing an array of first n multiples of an input number in JavaScript
- Multiples of 3 and 5 without using % operator in C++
- Python Program to Print Numbers in a Range (1,upper) Without Using any Loops
- Write a C program to print ‘ABCD’ repeatedly without using loop, recursion and any control structure
- Find m-th summation of first n natural numbers in C++
- Program to print numbers from 1 to 100 without using loop

Advertisements