Imports System
Public Class MainClass
Shared Sub Main(ByVal args As String())
Dim value As Integer = Convert.ToInt32(12)
Dim i As Integer
For i = 0 To value
Console.WriteLine( i & "! = " & Factorial(i) & vbCrLf )
Next
End Sub
' recursively generates factorial of number
Shared Function Factorial(ByVal number As Long) As Long
If number <= 1 Then ' base case
Return 1
Else
Return number * Factorial(number - 1)
End If
End Function ' Factorial
End Class
|