RosettaCodeData/Task/Sudan-function/OxygenBasic/sudan-function.basic

38 lines
722 B
Plaintext

uses console
'
function F(int n, x, y) as int
if n = 0 then
function = x + y
exit function
endif
if y = 0 then
function = x
exit function
endif
function = F(n - 1, F(n, x, y - 1), F(n, x, y - 1) + y)
end function
'
int n, x, y
for n = 0 to 1
printl " Values of F(" n ", x, y ):"
printl " y/x 0 1 2 3 4 5"
printl string(52, "-")
for y = 0 to 6
print " " y " |" tab
for x = 0 to 5
print F(n, x, y) tab
next x
printl
next y
printl
next n
'
printl "F(0,0,0) = " F(0, 0, 0)
printl "F(1,3,3) = " F(1, 3, 3)
printl "F(2,1,1) = " F(2, 1, 1)
printl "F(3,1,1) = " F(3, 1, 1)
printl "F(2,2,1) = " F(2, 2, 1)
printl cr "Enter ..."
waitkey