progs/fact.fun
author Christian Urban <urbanc@in.tum.de>
Sun, 13 Oct 2019 00:53:20 +0100
changeset 654 fb6192488b91
parent 626 2d91b2107656
child 655 3d04ee04966d
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
224
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     1
def fact(n) = if n == 0 then 1 else n * fact(n - 1);
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     2
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     3
def facT(n, acc) = if n == 0 then acc else facT(n - 1, n * acc);
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     4
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     5
facT(15, 1)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     6
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     7
//fact(15)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     8