The conversation between human and AI assistant.
What are the various types of algorithms that use recursion?
How does a recursive function work?
A recursive function works by calling itself with a smaller input until it reaches a base case, which is a condition that stops the recursion. In a factorial function, the base case is when n = 1, and the function returns 1. Then the function unwinds the stack of recursive calls, and multiplies the returned value with n to get the final result.