You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/06-advanced-functions/01-recursion/article.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -61,7 +61,7 @@ When `pow(x, n)` is called, the execution splits into two branches:
61
61
if n==1 = x
62
62
/
63
63
pow(x, n) =
64
-
\
64
+
\
65
65
else = x * pow(x, n - 1)
66
66
```
67
67
@@ -285,7 +285,7 @@ The iterative `pow` uses a single context changing `i` and `result` in the proce
285
285
286
286
**Any recursion can be rewritten as a loop. The loop variant usually can be made more effective.**
287
287
288
-
...But sometimes the rewrite is non-trivial, especially when function uses different recursive subcalls depending on conditions and merges their results or when the branching is more intricate. And the optimization may be unneeded and totally not worth the efforts.
288
+
...But sometimes the rewrite is non-trivial, especially when a function uses different recursive subcalls depending on conditions and merges their results or when the branching is more intricate. And the optimization may be unneeded and totally not worth the efforts.
289
289
290
290
Recursion can give a shorter code, easier to understand and support. Optimizations are not required in every place, mostly we need a good code, that's why it's used.
0 commit comments