Iteration or recursion. What is your favorite? In which cases? And why? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 10

Iteration or recursion. What is your favorite? In which cases? And why?

13th May 2018, 8:59 AM
SouthPoleHillbilly
SouthPoleHillbilly - avatar
3 Answers
+ 23
When both options are available I personally prefer loops. they are easier to understand and implement.(codes with loops are more readable) And I hate it when recursive functions sometimes result in "StackOverflow" for big arguments.
13th May 2018, 9:53 AM
Amir
Amir - avatar
+ 7
depends on language efficiency in js for ex recursion is more inefficiet than loops also recursion might be easier to use than loops but whatever you can do with recursion you can do with loops
13th May 2018, 9:12 AM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
+ 1
depends on efficenty. I like to use iterations for for loops.
21st May 2018, 5:35 PM
Apple Blossom
Apple Blossom - avatar