Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,10 @@
fun
fact
(
n: int
) : int = res where
{
var n: int = n
var res: int = 1
val () = while (n > 0) (res := res * n; n := n - 1)
}

View file

@ -0,0 +1,5 @@
fun
factorial
(n:int): int =
if n > 0 then n * factorial(n-1) else 1
// end of [factorial]

View file

@ -0,0 +1,8 @@
fun
factorial
(n:int): int = let
fun loop(n: int, res: int): int =
if n > 0 then loop(n-1, n*res) else res
in
loop(n, 1)
end // end of [factorial]