28 lines
513 B
Plaintext
28 lines
513 B
Plaintext
' FB 1.05.0 Win64
|
|
|
|
Function Factorial_Iterative(n As Integer) As Integer
|
|
Var result = 1
|
|
For i As Integer = 2 To n
|
|
result *= i
|
|
Next
|
|
Return result
|
|
End Function
|
|
|
|
Function Factorial_Recursive(n As Integer) As Integer
|
|
If n = 0 Then Return 1
|
|
Return n * Factorial_Recursive(n - 1)
|
|
End Function
|
|
|
|
For i As Integer = 1 To 5
|
|
Print i; " =>"; Factorial_Iterative(i)
|
|
Next
|
|
|
|
For i As Integer = 6 To 10
|
|
Print Using "##"; i;
|
|
Print " =>"; Factorial_Recursive(i)
|
|
Next
|
|
|
|
Print
|
|
Print "Press any key to quit"
|
|
Sleep
|