Tuesday, November 25, 2008

Fun with Recursion

I needed to backup a subdirectory and need to go through all subdirectories under it.

I used recursion to solve the problem.  

For those who don't know, recursion is when a function calls itself to solve a problem.  The classic example is factorial.  5 Factorial is 5*4*3*2*1.  here's a function to do that
Function Factorial (number as integer) as long
if number=1 then
return 1
        else
return factorial (number-1)*number
end if
end function

Run through the code

No comments: