O
O
Octet2021-05-07 07:26:26
recursion
Octet, 2021-05-07 07:26:26

Can any recursive calculation really be replaced by a non-recursive one?

And if so, why use recursion? Habit?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry Roo, 2021-05-07
@Octet

Quote from "Groaking Algorithms":
"Loops can speed up a program. Recursion can speed up a programmer. Choose what is more important in your situation!" Leigh Caldwell
Recursion or Iteration?

S
Sergey Gornostaev, 2021-05-07
@sergey-gornostaev

Recursion is expressive. The code of complex algorithms using recursion comes out more compact and more natural than using iteration.

A
Alexander, 2021-05-07
@Aleksandr-JS-Developer

In principle, you can not use cycles. Do not use your functions.
All these are language features, tools that greatly speed up development.
It cannot be said that a hammer is better than a screwdriver just because a self-tapping screw can be driven in with a hammer.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question