Skip to main content
Source Link
kd4ttc
  • 1.2k
  • 1
  • 13
  • 29

There are numerous good answers already posted, but let me add a very brief answer.

A tail recursive function when called recursively does not grow the stack.

This is the essential result of all the above explanations. The technique a programmer uses will vary from one problem to the next, but it often comes down to passing the pending result as an argument to the function rather than leaving a partial result on the stack.

See the above answer by Yilmaz who provides a factorial example.

Post Made Community Wiki by kd4ttc