Jump to content

Sudan function: Difference between revisions

Realize in F#
(add OCaml)
(Realize in F#)
Line 358:
</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}}==
{{works with|Factor|0.99 2022-04-03}}
2,172

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.