Sudan function: Difference between revisions
Content added Content deleted
(add OCaml) |
(Realize in F#) |
||
Line 358: | Line 358: | ||
</pre> |
</pre> |
||
=={{header|F_Sharp|F#}}== |
|||
{{trans|OCaml}} |
|||
<syntaxhighlight lang="fsharp"> |
|||
let rec sudan = function |
|||
0L, x, y -> x + y |
|||
|_, x, 0L -> x |
|||
|n, x, y -> let x' = sudan (n, x, y-1L) in sudan (n-1L, x', x' + y) |
|||
printfn "%d\n%d\n%d" (sudan(1L, 13L, 14L)) (sudan(2L, 5L, 1L)) (sudan(2L, 2L, 2L)) |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
245744 |
|||
440 |
|||
15569256417 |
|||
</pre> |
|||
=={{header|Factor}}== |
=={{header|Factor}}== |
||
{{works with|Factor|0.99 2022-04-03}} |
{{works with|Factor|0.99 2022-04-03}} |