blob: 6eccca9f909a7a1cf6bb1ed26d949de001ac25df (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
# Factorial of a number
def fact(n acc)
if =(n 1)
acc
else
# tagging a tail call with "@" so it can be optimized
@fact(-(n 1) *(acc n))
end
end
def main()
display("Running fact(50)...")
display(fact(50. 1))
end
|