Create a function that calculates the factorial of an integer without using loops (including For Next, For Each, Do Loop, etc.).
Remember that in most cases there is more than one way to solve the exercise.
Hint: It is possible to call a function inside its code (creating what is called recursion).
Function FatorialRec(n As Integer) As Integer If n = 0 Then FatorialRec = 1 Else FatorialRec = n * FatorialRec(n - 1) End If End Function
SuperExcelVBA.com is learning website. Examples might be simplified to improve reading and basic understanding. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. All Rights Reserved.
Excel ® is a registered trademark of the Microsoft Corporation.
© 2019 SuperExcelVBA | ABOUT
Thank you for contributing. A message was sent reporting your comment.