diff --git a/guide/english/mathematics/functions/recursively-defined-functions/index.md b/guide/english/mathematics/functions/recursively-defined-functions/index.md index 3801f7b5d8..42c82306d3 100644 --- a/guide/english/mathematics/functions/recursively-defined-functions/index.md +++ b/guide/english/mathematics/functions/recursively-defined-functions/index.md @@ -9,7 +9,59 @@ This is a stub. 5){ + return x + } + y = x + 1; + console.log(y); + foo(y); +} +``` +This is now equivalent to: + +```js +function foo(x){ + while(y < 5){ + y = x + 1; + console.log(y); + } +} +``` + +Almost everything that can be defined recursively can also be created with a loop. In fact, most compilers turn your code into a loop anyway, at some point, prior to it being executed. + +It should also be noted that recursion may look cool and allow you to shrink a long loop down into just a few lines of code but there are a few drawbacks. Mainly, performance of a recursive definition is generally slower than that of an iterative one, not to mention, it can be harder to read for people unfamiliar or new to the concept. + #### More Information: - - +- https://en.wikipedia.org/wiki/Recursion +- https://introcs.cs.princeton.edu/java/23recursion/