daily pastebin goal
57%
SHARE
TWEET

Recursion Example

CryptoJones Aug 30th, 2016 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top