Python program to print the first n multiples of given number

Here, we are going to write python program to print first n multiples of given numbers. To find multiples of n numbers, we can use for loop to print of each numbers one by on screen.

A multiple of a number is the product of the number and a counting number. So Lets see practical solved example. We can use following formula to solve the query.

Examples:

The numbers 2,4,6,8,10,122,4,6,8,10,12 are called multiples of 2. Multiples of 2 can be written as the product of a counting number and 2. The first six multiples of 2 are given below.

1*2=2

2*2=4

3*2=6

4*2=8

5*2=10

6*2=12

Program 1 : Python program to print multtiple of given numbers using for loop

# Python program to print the first n multiple of numbers
n = int(input("Enter number: "))

print("The multiples are: ")
for i in range(1,11):
    print(n*i, end =" ")


Output:

Enter number: 8
The multiples are:
8 16 24 32 40 48 56 64 72 80

Program 2 : Python program to print multiple of given numbers without using any loop

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 (*s) which print the array without using loop.

# Python program to print the first n multiple
# of a number n without using loop.
m = int(input("Enter number of term you want to print : "))
n = int(input("Enter any number : "))

# inserts all elements from n to
# (m * n)+1 incremented by n.
s = range(n, (m * n)+1, n)
print(*s)




Output:

Enter number of term you want to print : 20
Enter any number : 2
2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40

Python programs:

  • To find the sale price of an item with given cost and discount
  • To calculate perimeter/ circumference and area of shapes such as triangle, rectangle, square and circle
  • To calculate simple and compound interest
  • To calculate profit loss for a given cost and sale price
  • To calculate EMI for amount, period and interest
  • To calculate tax-GST/ income tax
  • <