+ 2

Recursive functions

When are recursive functions better than just loops? Because most of the examples is making a recursive function that counts a number's factorial, but using a loop is faster, and in my opinion better readable.

16th Jun 2019, 1:39 PM
Airree
Airree - avatar
1 Resposta
+ 10
Yes you are right loop is faster and readable. But in dynamic programming recursion is very useful. For instance Sometimes there is a question that is solved by splitting into small pieces and in this area recursion is very useful becz recurion recognize previous value. And helping to solve a complex problem.
16th Jun 2019, 2:39 PM
Sumit Programmer😎😎
Sumit Programmer😎😎 - avatar