Recursion : What is Function Recursion

Printable View

- 03-03-2008khushalanswer me plezz ?????
Recursion : What is Function Recursion

- 03-03-2008swgh
A recursive function is a function that calls itself. It uses a base step and a recursive step.

- 03-03-2008khushalneed further explanation
Can you explain it by giving a simple example of addition or multiplication plezz

- 03-03-2008rags_to_riches
- 03-03-2008MacGyver
Consider a factorial of a number. Let's go with this as a definition: n! = n * n-1 * n-2 .... * 1

Now let's talk about 5 factorial, written as "5!".

5! can be written two ways.

- 5! = 5 * 4 * 3 * 2 * 1
- 5! = 5 * 4!

The first view is iterative. The second is recursive.

There's your example. - 03-03-2008matsp
A recursive multiplication (very stupid implementation, but it does the required task):

Code:`int mul_rec(int x, int y)`

{

if (x == 0) return 0;

if (x == 1) return y;

return mul_rec(x - 1, y);

}

--

Mats - 03-03-2008khushalneed further explanation for:
need and explanation about addition and subtraction of numbers entered through an 1 D array

- 03-03-2008Fordy
Do your own homework