summaryrefslogtreecommitdiff
path: root/io/fib.io
blob: 46a6d54a576214fd9edb40e847a852d617fa052c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
fib_rec := method(pos,
	if (pos == 1 or pos == 2) then (
		return 1
	) else (
		return fib_rec(pos-1) + fib_rec(pos-2)
	)
)

fib_loop := method(pos,
	fst := 0
	snd := 1
	result := nil
	(pos-1) repeat (
		result := fst + snd
		fst := snd
		snd := result
	)
	return result
)

n := 4
fib_rec(n) println
fib_loop(n) println