Given n and m, print first m multiples of a m number without using any loops in Python.
Input : n = 2, m = 3 Output : 2 4 6 Input : n = 3, m = 4 Output : 3 6 9 12
We can use range() function in Python to store the multiples in a range.
First we store the numbers till m multiples using range() function in an array, and then print the array with using (*a) which print the array without using loop.
Below is the Python implementation of the above approach:
3 6 9 12
Note : In Python 3,
print(*(range(x)) is equivalent to
print(" ".join([str(i) for i in range(x)]))
- Python | Using for loop in Flask
- Using else conditional statement with for loop in python
- How to print without newline in Python?
- Python | sep parameter in print()
- Python | end parameter in print()
- Print with your own font using Python !!
- Python | Output using print() function
- Python program to print Emojis
- Print lists in Python (4 Different Ways)
- Python | file parameter in print()
- Print Colors in Python terminal
- Python | Print the initials of a name with last name in full
- Python | Print all sublists of a list
- Python | Print diagonals of 2D list
- Ways to print escape characters in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.