19 lines
443 B
Plaintext
19 lines
443 B
Plaintext
class Fib
|
|
private function fib_i(integer n)
|
|
return iff(n<2?n:this.fib_i(n-1)+this.fib_i(n-2))
|
|
end function
|
|
public function fib(integer n)
|
|
if n<0 then throw("constraint error") end if
|
|
return this.fib_i(n)
|
|
end function
|
|
end class
|
|
Fib f = new()
|
|
|
|
function fib_i(integer i)
|
|
return sprintf("this is not the fib_i(%d) you are looking for\n",i)
|
|
end function
|
|
|
|
?f.fib(10)
|
|
--?f.fib_i(10) -- illegal
|
|
?fib_i(10)
|