Stuff
public text v1 · immutablefib
"returns the fibonacci value of myself
by Nathan Wallace. Started April 17, 2007"
(self = 0)
ifTrue: [^ 0]
ifFalse:[ (self = 1)
ifTrue: [^ 1]
ifFalse:[(self >= 2)
ifTrue:[ ^(((self - 1) fib) + ((self - 2) fib))]
ifFalse:[^-1]]]
"Example Run:
Command: 0 fib.
Result: 0
Command: 1 fib.
Result: 1
Command: 2 fib.
Result: 1
Command: 25 fib.
Result: 75025"! !