Friday, 9 August 2013

How to Write Recursive Procedures

A recursive procedure is one that calls itself. Example is as follows –
The following procedure uses recursion to calculate the factorial of its original argument.
Function factorial(ByVal n As Integer) As Integer
If n <= 1 Then
Return 1
Else
Return factorial(n – 1) * n
End If
End Function

No comments:

Post a Comment