View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Frank Kabel Frank Kabel is offline
external usenet poster
 
Posts: 3,885
Default General question

Hi David
one reason is the use for recursive algorithms. e.g. calculation of the
factorial (e.g. 5! =1*2*3*4*5):
Function fact(i as integer) as long
If i = 0 then
fact = 1
else
fact = i*fact(i-1)
end if
end function
Of course you can achieve this without recursion but this way its
'easier' to read.

you may have a look at the following site:
http://cse.unl.edu/~dsadofs/Recursio...p?s=algorithms
for more information (or just do a google search for 'recursive
algorithms')

HTH
Frank



David wrote:
Can anyone tell me the use of calling a sub inside itself.... please
Just some exemple to understand the uses
Thx for your help!