blob: 1a2ae684a884f08e284bbdd9f4ffed893db88a82 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
/ Takes an index in the fibonacci sequence on the stack
/ Returns a number of the fibonacci sequence with a given index
F {
/ Let us define some local variables
&a &b &c
/ If index is zero or one then we just return the number
?c #; $c+ = c
?c #;
/ Otherwise we get previous two numbers of the sequence
/ and return their sum
= c $c $c
- @F = a
-- @F = b
$a $b*
}
^+++++++++++++++++++++++=t$t
$t@F
|