Sudan function: Difference between revisions
Content added Content deleted
(Added C# implementation) |
(Added R implementation) |
||
Line 237: | Line 237: | ||
</pre> |
</pre> |
||
=={{header|R}}== |
|||
{{trans|C}} |
|||
<lang R> |
|||
F <- function(n, x, y) { |
|||
if(n==0){ |
|||
F <- x+y |
|||
return (F) |
|||
} |
|||
else if(y == 0) { |
|||
F <- x |
|||
return (F) |
|||
} |
|||
F <- F(n - 1, F(n, x, y - 1), F(n, x, y - 1) + y) |
|||
return (F) |
|||
} |
|||
print(paste("F(1,3,3) = " , F(1,3,3))) |
|||
</lang> |
|||
Output |
|||
<pre> |
|||
[1] "F(1,3,3) = 35" |
|||
</pre> |
|||
=={{header|Wren}}== |
=={{header|Wren}}== |
||
{{libheader|Wren-fmt}} |
{{libheader|Wren-fmt}} |