29 lines
451 B
Text
29 lines
451 B
Text
|
|
sub fac(self$, n)
|
||
|
|
if n > 1 then
|
||
|
|
return n * execute(self$, self$, n - 1)
|
||
|
|
else
|
||
|
|
return 1
|
||
|
|
end if
|
||
|
|
end sub
|
||
|
|
|
||
|
|
sub fib(self$, n)
|
||
|
|
if n > 1 then
|
||
|
|
return execute(self$, self$, n - 1) + execute(self$, self$, n - 2)
|
||
|
|
else
|
||
|
|
return n
|
||
|
|
end if
|
||
|
|
end sub
|
||
|
|
|
||
|
|
sub test(name$)
|
||
|
|
local i
|
||
|
|
|
||
|
|
print name$, ": ";
|
||
|
|
for i = 1 to 10
|
||
|
|
print execute(name$, name$, i);
|
||
|
|
next
|
||
|
|
print
|
||
|
|
end sub
|
||
|
|
|
||
|
|
test("fac")
|
||
|
|
test("fib")
|