## Examples of Iterative and Recursive Algorithms in Java

An algorithm is a procedure or formula for solving a problem. If you need to repeat some steps in the procedure you can opt Iterative algorithm or Recursive algorithm. Recursion and iteration are just two different code structures with the same end result. The difference between them is that recursion is simply a method call in which the method being called is the same as the one making the call while iteration is when a loop is repeatedly executed until a certain condition is met.

## Recursion

Recursion is a process in which a method(function) calls itself directly(simple recursion) or indirectly(through other functions(complex or indirect recursion)). For example function A calls function B, and function B calls function A. The number of nested calls to a function(or procedure) is called recursion depth. A recursive function allows you to write clean code, without explicit repetition of parts of the code and the use of loops. The Recursive Algorithm uses a selection structure and makes code smaller.

## How to Sum the numbers from 1 to N

### Arithmetic Progression

https://en.wikipedia.org/wiki/Arithmetic_progression