Use of recursion for repetitive algorithms


Use of recursion for repetitive algorithms

Use of recursion for repetitive algorithms

Recursion means that a function is calling itself to acomplish the condition given before, this is very useful when we need a number or sum to have a limit, that way we can give the program an instruction on when to stop adding.
In my example I just put in a countdown.
As you can see there is a “recur(n-1)” thing there, that means that the number given, is going to be reduced by one until zero is reached.

CC BY 4.0 Use of recursion for repetitive algorithms by Salvador García is licensed under a Creative Commons Attribution 4.0 International License.

Comments are closed.