Q. Implement a function product() to multiply 2 numbers recursively using + and - operators only.
You can understand by Watching video :-
Answer =
def product( num1 , num2 ): if 0 == num2 : return 0 else : return product(num1 , num2 - 1 ) + num1 a = int(input("Enter a number : ")) b = int(input("Enter second number :")) print(product( a , b))
Output :-
Enter a number : 5
Enter second number :6
30
>>>
Enter a number : 75
Enter second number :2
150
>>>
Enter a number : 10000
Enter second number :89
890000
>>>
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )