sum_acc(n, acc=0) that sums the integers from 1 to n using the tail-recursive pattern: an accumulator parameter carries the running total forward with each call, so the addition happens *before* recursing rather than after the recursive call returns (unlike a naive n + sum_acc(n - 1)).sum_acc(5)
15
1+2+3+4+5 = 15, accumulated as acc grows: 5,9,12,14,15.
sum_acc(0)
0
Base case returns the accumulator unchanged.
Base case: n == 0, return acc.
Recursive case: sum_acc(n - 1, acc + n) — note Python does not actually optimize tail calls, but the pattern still matters for reasoning about call structure.