Recursive Procedures : Recursive « Language Basics « VBA / Excel / Access / Word






Recursive Procedures

 
Function GetFactorial(intValue As Integer) As Double
    If intValue <= 1 Then
        GetFactorial = 1
    Else
        GetFactorial = GetFactorial(intValue - 1) * intValue
    End If
End Function

Sub RecursiveFunction()
   Debug.Print GetFactorial(3)
End Sub

 








Related examples in the same category

1.A recursive procedure is one that calls itself.
2.Recursive function to calculate the faculty of x