blob: 29b73c3871d569e52156a3730a267555b35c9afa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
//
// Factorial, with recursive tail call optimization
//
def fact(n number, acc number) number {
if n == 1 {
return acc;
} else {
return fact(n - 1, acc * n);
}
}
println("fact 20: ", fact(20, 1));
|