Issue
because i found it hard to get
take a look:
def mult(a, b):
if b == 0:
return 0
rest = mult(a, b - 1)
value = a + rest
return value
prod = int(input('Enter number: '))
print('The product of', prod, 'x', prod, 'is', mult(prod,prod))
Solution
Just start with
def mult(a, b):
if b<0: return -mult(a, -b)
and continue with the code you have now (assuming the latter's indented properly -- right now it's something of a mess but I'll assume that's merely a formatting issue and the code will work if properly edited:-).
Answered By - Alex Martelli
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.