**Recursion** in computer science is a method where the solution to a problem depends on solutions to smaller instances of the same problem. The approach can be applied to many types of problems, and is one of the central ideas of computer science.

Using a for or while loop to print the numbers from one to ten is an iterative process. An Iterative function is one that loops to repeat some part of the code until the specified condition is not satisfied. A Recursive function is one that calls itself again and again to repeat part of a code.

function factorial(n) { var i, result; result = 1; for(i=1; i<=n; i++) { result = result * i; } return result; }

function fact(k) { if (k == 0) { return 1; } else { return k * fact(k - 1); } }

**Let us consider these three factors to decide whether to use Iteration or Recursion.**

- Iterative functions are preferred over their recursive counterparts in case of speed. So, if speed is to be considered, then we can use iteration.
- Stack limit is another factor while preferring iteration over recursion.
- The procedures which are very programmed recursively naturally, and are unmanageable iteratively then the recursive functions are preferred over iteration.

Many mathematical functions can be defined recursively:

- Factorial
- Fibonacci
- Euclid's GCD (Greatest Common Denominator)
- Fourier Transform

Many problems can be solved recursively, eg games of all types from simple ones like the Towers of Hanoi problem to complex ones like chess. In games, the recursive solutions are particularly convenient because, having solved the problem by a series of recursive calls; you want to find out how you got to the solution. By keeping track of the move chosen at any point, the program call stack does this housekeeping for you!

Try our determination care now, solution of your problem is righteous a depression departed. Knock any quantify at our 24x7 live supports for any ask. To know about how to proceed, just visit how it Works page at Assignmenthelp.net.

To schedule a **Iteration And Recursion** tutoring session Click here

Basic Subject

Computer Science

- Programming Assignment Help
- Database Help
- Data Structure Assignment Help
- Operating Systems Assignment Help
- Computer Network Assignment Help
- UML Diagram Assignment Help
- IT Assignment Help
- Game Programming
- Computer Science Assignment Help
- Medical Science Assignment Help
- Social Science Assignment Help
- Information Systems

Engineering

- Biochemical and Biotechnology Help
- Chemical Engineering Assignment
- Statistics Assignment Help
- Civil Engineering Assignment Help
- Electrical, Electronics Help
- Mathematics, Computing Assignment Help
- Mechanical and Industrial Engg. Help
- Petroleum Engg. Assignment Help
- Biochemistry Assignment Help
- Cell Biology Assignment Help
- Arts and Architecture Help
- Silverlight Assignment Help