Recursion termination: Difference between revisions

Content deleted Content added
Fix Python definition
m linking
Line 16:
3. Otherwise, return [fibonacci(n-1) + fibonacci(n-2)]
 
This recursive function [[termination (computer science)|terminates]] if either conditions 1 or 2 are satisfied. We see that the function's recursive call reduces the value of n(by passing n-1 or n-2 in the function) ensuring that n reaches either condition 1 or 2.
 
If we look at an example of this in Python we can see what's going on a bit more clearly: