New course! Every coder should learn Generative AI!
Try a free lesson+ 2
function HeadRecursion(arg) {
value = HeadRecursion(arg-1)
//There are more tasks to do after the recursive call
print(arg)
return value
}
function TailRecursion(arg) {
print(arg)
return TailRecursion(arg-1)
//There's nothing else to do after the recursive call, good
}
There is a lot of documentation on this topic online. Please use your favorite search engine and surf the net. Keywords: "tail call head call recursion TCO", etc.