Recursion is a technique in which a function calls itself.
There are two parts to recursion:
A simple example is a factorial problem. A factorial of n multiples all the numbers from 1 to n. For example, 5! is 5*4*3*2*1
How would we write a recursive function to solve this?
Code:
(define (factorial n)
(if (= n 1)
1
(* n (factorial (- n 1))))
)
Tail recursion is a special type of recursion in which the value to return is tracked throughout the recursion.