author | Christian Urban <christian dot urban at kcl dot ac dot uk> |
Tue, 20 Sep 2016 12:17:01 +0100 | |
changeset 421 | 7a04f2c532c1 |
parent 224 | 70198792c2aa |
permissions | -rw-r--r-- |
224
70198792c2aa
added
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); |
70198792c2aa
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2 |
|
70198792c2aa
added
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); |
70198792c2aa
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
4 |
|
70198792c2aa
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
5 |
facT(15, 1) |
70198792c2aa
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
6 |
|
70198792c2aa
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
7 |
//fact(15) |
70198792c2aa
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
8 |