In this artical we are going to discuss python program to multiply two numbers by repeated addition. So lats start...

Python Program to multiply two numbers by repeated addition.

num1=int(input("Enter first number "))
num2=int(input("Enter second number "))
product=0
for i in range (1,num2+1): 
     product=product+num1      
print("The multiply is: ",product)

Output:          

           Enter first number 6
           Enter second number 7
           The multiply is:  42


 

Let's breakdown this problem into sub parts so that we can easily solve the given problem

Step 1 : First we take input from user by input() function and convert it to integer by int() function.

Step 2 : Now i take a third variable named as product, in this variable we store the result of two numbers calculated by the python program.

Step 3 : Now i run a loop through on second number and added the first number with product variable and store the result on product variable.

So this is a simple method to find the repeated addition of two numbers without function in Python.

 

Python Program to multiply two numbers by repeated addition using function.

def multiply(a,b):
    sum=0
    for i in range(b):
        sum=sum+a
    print("The multiply is: ",sum)

num1=int(input("Enter first number "))
num2= int(input("Enter second number "))
multiply(num1,num2)

 

Output:

           Enter first number 6
           Enter second number 7
           The multiply is:  42

 

This is a example of how can we calculate repeated addition using function in python. in this approach we take values from user and pass into the function and all logic as same above method.