Factorial in Boo
Example for versions
boo 0.8.2
This example uses iterative factorial definition. Variable fact needs an explicit type declaration, since otherwise it will be typed as int, and trying to calculate 13! will cause an overflow error.
fact as long = 1
for i in range(17):
print("${i}! = ${fact}")
fact = fact * (i+1)
Comments
]]>blog comments powered by Disqus
]]>