RosettaCodeData/Task/Ackermann-function/FutureBasic/ackermann-function.futurebasic

37 lines
664 B
Plaintext

include "ConsoleWindow"
def tab 1
begin globals
dim as container gC
end globals
def fn Ackerman( m as long, n as long ) as long
local fn Ackerman( m as long, n as long ) as long
dim as long result
if m == 0 then result = n + 1 : exit fn
if ( n == 0 )
result = fn Ackerman( m - 1, 1 )
exit fn
end if
result = fn Ackerman( m - 1, fn Ackerman(m, n - 1) )
end fn = result
dim as long n, m
/*
Cache response in global string container to speed
processing rather printing each iteration.
*/
for m = 0 to 3
for n = 0 to 10
gC += "fn ackerman(" + str$(m) + "," + str$(n) + " ) =" + Str$( fn Ackerman( m, n ) ) + chr$(13)
next
next
print gC