changeset 735 | fc2e3609d5e5 |
parent 702 | 39e21a33ffb0 |
child 814 | 1fbaa5f05516 |
734:5d860ff01938 | 735:fc2e3609d5e5 |
---|---|
1 def fact(n) = |
|
2 (if n == 0 then 1 else n * fact(n - 1)); |
|
3 |
|
4 def facT(n, acc) = |
|
5 if n == 0 then acc else facT(n - 1, n * acc); |
|
6 |
|
7 def facTi(n) = facT(n, 1); |
|
8 |
|
9 //fact(10) |
|
10 //facTi(10) |
|
11 |
|
12 write(facTi(6)) |
|
13 |
|
14 // a simple factorial program |
|
15 // (including a tail recursive version) |