Factorial in Basic
Example for versions
Microsoft Visual Basic .NET 9 (2008),
vbnc 2.4.2
This example uses recursive factorial definition.
Module Module1
Function Factorial(ByVal n As Integer) As Long
If n = 0 Then
Return 1
Else
Return n * Factorial(n - 1)
End If
End Function
Sub Main()
For i As Integer = 0 To 16
Console.WriteLine(i & "! = " & Factorial(i))
Next
End Sub
End Module
Comments
]]>blog comments powered by Disqus
]]>