
#python #pythonpomoc
czemu to daje wynik 15?
def tailSum (n,acuumulator=0):
if n==0:
return acuumulator
else:
return tailSum(n-1, acuumulator+n)
print(tailSum(5))czemu to daje wynik 15?
- Najlepsze
- Wszystkie komentarze







@borrow: bo w każdym wywołaniu rekurencyjnym do acuumulator dodajesz n, które leci od jedynki w górę?
1+2+3+4+5 = 15
print(n,acuumulator)
5 0
Komentarz usunięty przez autora