23 lines
631 B
Text
23 lines
631 B
Text
with javascript_semantics
|
|
function F(integer n, x, y)
|
|
if n=0 then return x+y end if
|
|
if y=0 then return x end if
|
|
integer t = F(n,x,y-1)
|
|
return F(n-1,t,t+y)
|
|
end function
|
|
|
|
for n=0 to 1 do
|
|
printf(1,"Values of F(%d, x, y):\n",n)
|
|
printf(1,"y/x 0 1 2 3 4 5\n")
|
|
printf(1,"----------------------------\n")
|
|
for y=0 to 6 do
|
|
sequence r = apply(true,F,{n,tagset(5,0),y})
|
|
printf(1,"%d |%s\n",{y,join(r,"",fmt:="%4d")})
|
|
end for
|
|
printf(1,"\n")
|
|
end for
|
|
|
|
for t in {{2,1,1},{3,1,1},{2,2,1}} do
|
|
integer {n,x,y} = t
|
|
printf(1,"F(%d, %d, %d) = %d\n",{n,x,y,F(n,x,y)})
|
|
end for
|