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
0! = 1
1! = 1
2! = 2
3! = 6
4! = 24
5! = 120
6! = 720
7! = 5040
8! = 40320
9! = 362880
10! = 3628800
11! = 39916800
12! = 479001600