Factorial
This algorithm finds the factorial of a given number.
Public Shared Function Factorial(number As Integer) As Long
If number < 0 Then
Return -1 'Error
End If
Dim result As Long = 1
For i As Integer = 1 To number
result *= i
Next
Return result
End Function
Example
Dim _factorial = Factorial(10)
Output
3628800