This is an example from Eloquent Javascript:
By starting from the number 1 and repeatedly either adding 5 or multiplying by 3, an infinite amount of
Lets leave the history parameter, we'll get to it later.
The recursion expands to all possible operations.
It starts with the value 1 as start.
We first check if we reached our destination: goal, if we did- return true, meaning the path we took is correct.
Second, we ask- did we go over the bound (goal)? If we did, we should return false since this path can't help us.
Otherwise, lets try our two possiblities (We use OR because we need at least one):
start to start + 5start to start * 3The history variable keeps the steps we take. So if a function call identifies that start == goal it returns it.