Public Class Tester
Public Shared Sub Main
Dim value As Integer = 12
Dim i As Integer
For i = 0 To value
Console.WriteLine(i & "! = " & Factorial(i))
Next
End Sub
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
|