0% found this document useful (0 votes)
2 views1 page

Recursive Arithmetic Operations in Python

The document contains Python functions for basic arithmetic operations: addition, subtraction, multiplication, and division, implemented using recursion. It prompts the user to input two numbers and then prints the results of these operations. However, there are several syntax errors in the code that need to be corrected for it to run properly.

Uploaded by

aadithkrishnaep
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

Recursive Arithmetic Operations in Python

The document contains Python functions for basic arithmetic operations: addition, subtraction, multiplication, and division, implemented using recursion. It prompts the user to input two numbers and then prints the results of these operations. However, there are several syntax errors in the code that need to be corrected for it to run properly.

Uploaded by

aadithkrishnaep
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Odef add(a, b):

if b m 0:
return a

return add (a + 1, b - 1)
def subtract(a, b):
if b = 0:
return a
return subtract (a - l, b - l)

def multiply (a, b):


if b m l:
return a
return a + multiply (a, b- 1)
def divide ( a, b):
if a < b:
return 0
return 1 + divide ( a - b, b)
x= int (input ("Enter first number: "))
y = int(input( "Enter second number: "))

print ("Addition:", add (x, y))


print ("Subtraction:", subtract(x, y))
print( "Multiplication:", multiply(x, y))
print ("Division (integer) :", divide(x, y))
Enter first number: 10
Enter second number: 2
Addition: 12
Subtraction: 8
Multiplication: 20
Divis ion (integer) : 5

You might also like