16 lines
371 B
Plaintext
16 lines
371 B
Plaintext
$ Print out the first ten Fibonacci numbers
|
|
$ This uses Set Builder Notation, it roughly means
|
|
$ 'collect fib(n) forall n in {0,1,2,3,4,5,6,7,8,9,10}'
|
|
print({fib(n) : n in {0..10}});
|
|
|
|
$ Iterative Fibonacci function
|
|
proc fib(n);
|
|
A := 0; B := 1; C := n;
|
|
for i in {0..n} loop
|
|
C := A + B;
|
|
A := B;
|
|
B := C;
|
|
end loop;
|
|
return C;
|
|
end proc;
|