Recursive Functions

Recursive Functions - Andy Patrachari Spring 2011 Recursive Functions Recursion is a process by which a program tends to repeat itself multiple

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Andy Patrachari Spring 2011 Recursive Functions Recursion is a process by which a program tends to repeat itself multiple times until a specific criterion is satisfied (decided by the programmer). A function that calls itself repeatedly is called as a recursive function. Recursion is a power tool available in computers that helps programming certain aspects simpler. Some examples where recursion can be used include calculating the factorial of a number, calculating sum of all the numbers from 1 to a specific user entered value, all the various summation and series type calculations in mathematics, etc. The sample function below illustrates the application of recursion (recursive functions) to calculate the sum of all the integer numbers starting from 1 and going to a particular user entered value (n), say 5. Before looking at the actual program, let’s take a look at the actual mathematics (and logic) behind the calculation. Let us represent sum of all the numbers from 1 to ‘n’ as Sum_n(n).
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/12/2011 for the course ENGR 1412 taught by Professor Staff during the Spring '08 term at Oklahoma State.

Page1 / 4

Recursive Functions - Andy Patrachari Spring 2011 Recursive Functions Recursion is a process by which a program tends to repeat itself multiple

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online