Here's the recursive code:
def trace(a, b): if (a > b): return -1 elif (a == b): print (a * a) return a * a else: m = (a + b) / 2 return trace (a, m) + trace (m + 1, b) x=trace(1,4)
while I'm not sure what this function should do, we must find the result x=trace(1,4) together with the value x manually (this means that we cannot use downtime to help us).
After some time, I determined that the function would print 1 and 12.25, which would be output when assigning x to trace(1,4) .
However, I don’t know how to determine what the value of X will be. Although the answer is -91.75, I have no idea how it was received (although I know how it will take a long time to come up with this answer, and I don’t sure how we can quickly come up with in a short period of time, for example, when writing an exam).
Thanks in advance for your help!
source share