Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
22
Task/Fibonacci-sequence/S-BASIC/fibonacci-sequence.basic
Normal file
22
Task/Fibonacci-sequence/S-BASIC/fibonacci-sequence.basic
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
rem - iterative function to calculate nth fibonacci number
|
||||
function fibonacci(n = integer) = integer
|
||||
var f, i, p1, p2 = integer
|
||||
p1 = 0
|
||||
p2 = 1
|
||||
if n = 0 then
|
||||
f = 0
|
||||
else
|
||||
for i = 1 to n
|
||||
f = p1 + p2
|
||||
p2 = p1
|
||||
p1 = f
|
||||
next i
|
||||
end = f
|
||||
|
||||
rem - exercise the function
|
||||
var i = integer
|
||||
for i = 0 to 10
|
||||
print fibonacci(i);
|
||||
next i
|
||||
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue