Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
23
Task/Fibonacci-sequence/Turing/fibonacci-sequence.turing
Normal file
23
Task/Fibonacci-sequence/Turing/fibonacci-sequence.turing
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
% Recursive
|
||||
function fibb (n: int) : int
|
||||
if n < 2 then
|
||||
result n
|
||||
else
|
||||
result fibb (n-1) + fibb (n-2)
|
||||
end if
|
||||
end fibb
|
||||
|
||||
% Iterative
|
||||
function ifibb (n: int) : int
|
||||
var a := 0
|
||||
var b := 1
|
||||
for : 1 .. n
|
||||
a := a + b
|
||||
b := a - b
|
||||
end for
|
||||
result a
|
||||
end ifibb
|
||||
|
||||
for i : 0 .. 10
|
||||
put fibb (i) : 4, ifibb (i) : 4
|
||||
end for
|
||||
Loading…
Add table
Add a link
Reference in a new issue