Advertisement
CryptoJones

Recursion Example

Aug 30th, 2016
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.38 KB | None | 0 0
  1.     Function Factorial(n As Integer) As Integer
  2.         Console.WriteLine(n)
  3.         if (n = 1) Then
  4.             return 1
  5.         Else
  6.             Dim result As Integer = n * Factorial(n - 1)
  7.             Console.WriteLine(n)
  8.             Return result
  9.         End If
  10.     End Function
  11.  
  12.     Sub Main()
  13.         Dim f As Integer = factorial(4)
  14.         Console.WriteLine(f)
  15.     End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement