+ 2
My laptop lags when I am using this recursive function.WHY?
Although I am using a base case, my laptop cannot run the function: def compute(n): if n==1: return 1 else: return (n**2) + compute((n-1)**2)
1 Respuesta
+ 2
You maybe rather want to do:
def compute(n):
if n==1:
return 1
else:
return (n**2) + (compute(n-1)**2)
;)