Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
27
Task/Factorial/FreeBASIC/factorial.basic
Normal file
27
Task/Factorial/FreeBASIC/factorial.basic
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
' 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue