Recursive Methods!!!

Hi.. could anyone give me a nice summary of Recursive methods and how they work and how to read them?much thanks!!
[128 byte] By [JavaBamfa] at [2007-11-26 16:46:18]
# 1

A recursive algorithm solves a problem by solving a little bit of the problem, leaving a simpler version of the problem left over. Then it solves that remaining problem the same way.

For example, the factorial of N is either;

1, if N is 1, or

N times the factorial of (N-1)

For more detail, read a textbook or Wikipedia or something.

[add]

Well it looks like NotN made the Wikipedia option really easy for you.

Message was edited by:

paulcw

paulcwa at 2007-7-8 23:13:43 > top of Java-index,Java Essentials,New To Java...
# 2
<pbs>The factorial of zero is also 1 and for any negative number it should raise an exception.</pbs>
floundera at 2007-7-8 23:13:43 > top of Java-index,Java Essentials,New To Java...
# 3

//example of recursive method that calculate sum of Integer element

//at vector object

public static int sum_list(Vector<Integer> vint, int i){

if (i == vint.size()){

return 0;

} else {

return vint.elementAt(i++) + sum_list(vint, i);

}

}

//

regards

p_epi

p_epia at 2007-7-8 23:13:43 > top of Java-index,Java Essentials,New To Java...