449
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1 |
object FactT {
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
3 |
def factT(n: Int, acc: Int): Int =
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
4 |
if (n == 0) acc else factT(n - 1, n * acc)
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
5 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
6 |
}
|