Recursive function to calculate the faculty of x : Recursive « Language Basics « VBA / Excel / Access / Word






Recursive function to calculate the faculty of x

 
Public Sub testrecur()
  Debug.Print recur(3)
End Sub

Function recur(x)
  If x <= 1 Then
    recur = 1
  Else
    recur = x * recur(x - 1)
  End If
End Function

 








Related examples in the same category

1.Recursive Procedures
2.A recursive procedure is one that calls itself.