+ 1
Explain Recursion please
4 Answers
+ 3
Explain xkcd
https://www.explainxkcd.com/wiki/index.php/244:_Tabletop_Roleplaying
From the link:
...a new game inside the game they're currently playing. "Recursing" refers to "recursion," a concept of computer programming where a piece of code calls itself, essentially making the code run multiple times "within" itself. Looping is a rudimentary form of recursion.
Recursion speed can be the same as iteration. Recursive functions are easier to write, understand and maintain than the same algorithms made complex using iteration.
+ 2
Recursion is when a method calls itself inside itself.
+ 2
recursion is a method in which function call itself. Used mainly when try to find value after a loop has execute like factorial value. It make your function slow, try to avoid if you don't like slow program.
+ 1
Recursion is a very important idea, but not so complicated, and he is not just a programming technique.
In general, a recursive definition consists of two parts. There is at least one base case that directly determines the outcome of a given case, and at least one recursive (inductive) case to determine the results of this case based on the results of other problems, generally a simplified version of the same problem.
For example:
The factorial function of a natural number may be the simplest recursive definition in the world. A typical induction definition:
1! = 1
(n+1)! = (n+1) * n!
The first equation defines the base case. The second equation uses the factorial of the previous number to define the factorial of all natural numbers except the base case.