Sudan function: Difference between revisions

Sudan function in Gambas
(Sudan function in Dart)
(Sudan function in Gambas)
Line 309:
return F(n - 1, F(n, x, y - 1), F(n, x, y - 1) + y)
end function</syntaxhighlight>
{{out}}
<pre>Same as FreeBASIC entry.</pre>
 
==={{header|Gambas}}===
{{trans|FreeBASIC}}
<syntaxhighlight lang="vbnet">Function F(n As Integer, x As Integer, y As Integer) As Integer
If n = 0 Then Return x + y
If y = 0 Then Return x
Return F(n - 1, F(n, x, y - 1), F(n, x, y - 1) + y)
End Function
 
Public Sub Main()
Dim n, x, y As Integer
 
For n = 0 To 1
Print " Values of F(" & n & ", x, y):"
Print " y/x 0 1 2 3 4 5"
Print String(29, "-") 'Print " ----------------------------"
For y = 0 To 6
Print y; " | ";
For x = 0 To 5
Print Format$(F(n, x, y), "####");
Next
Print
Next
Print
Next
Print "F(2,1,1) = "; F(2, 1, 1)
Print "F(3,1,1) = "; F(3, 1, 1)
Print "F(2,2,1) = "; F(2, 2, 1)
End </syntaxhighlight>
{{out}}
<pre>Same as FreeBASIC entry.</pre>
2,130

edits