Sudan function: Difference between revisions

add REXX
(→‎{{header|OCaml}}: added =={{header|Pascal}}== trans Delphi tested SudanFunction( 2, 2, 2) =15,569,256,417)
(add REXX)
Line 1,389:
- : int = 15569256417
</pre>
=={{header|REXX}}==
<syntaxhighlight lang="rexx">
/* REXX implement the SUDAN function */
Say '+---++-------------------------+'
Say '| y ||x= 0 1 2 3 4 5 |'
Say '+===++=========================+'
Do y=0 To 6
s='|' y '||'
Do x=0 To 5
s=s format(sudan(x,y),3)
End
Say s '|'
End
Say '+===++=========================+'
Exit
 
sudan: Procedure
Parse Arg x,y
Return sudan1(1,x,y)
 
sudan1: Procedure
Parse Arg n,x,y
Select
When n=0 Then Return x+y
When y=0 Then Return x
Otherwise Return sudan1(n-1,sudan1(n,x,y-1),sudan1(n,x,y-1)+y)
End</syntaxhighlight>
{{out|output}}
<pre>+---++-------------------------+
| y ||x= 0 1 2 3 4 5 |
+===++=========================+
| 0 || 0 1 2 3 4 5 |
| 1 || 1 3 5 7 9 11 |
| 2 || 4 8 12 16 20 24 |
| 3 || 11 19 27 35 43 51 |
| 4 || 26 42 58 74 90 106 |
| 5 || 57 89 121 153 185 217 |
| 6 || 120 184 248 312 376 440 |
+===++=========================+</pre>
 
=={{header|Pascal}}==
==={{header|Pascal}}===
2,295

edits