#mastery22 When to use what type of repetition in a program

In program i think it’s better to make iterative solutions, i’ll show you why:

Recursive solution:

The difference is that when using a recursion it takes alot of time to print as you can see in the picture, iterative solution printed the answer when recursive solution is still calculating the fibonacci of 100.

It is also convenient to use recursion because an infinite loop occurs with iteration if the loop test never becomes false.

The difference is that iteration ends terminates when the loop condition falls whereas recursion terminates when a base case is recognized.

Here are some of the differences of both: http://malhar2010.blogspot.mx/2010/12/difference-between-recursion-and.html

Gilberto Rogel García

CC BY 4.0 #mastery22 When to use what type of repetition in a program by Gilberto Rogel García is licensed under a Creative Commons Attribution 4.0 International License.

Comments are closed.