Factorial in Cat
Example for versions
Online Cat 1.3
This example uses recursive factorial definition, and works in a similar way to Fibonacci numbers example.
define fact {
dup 1 <=
[pop 1]
[dup 1 - fact *]
if
}
0
[dup write "! = " write dup fact writeln inc]
[dup 16 lteq]
while
Comments
]]>blog comments powered by Disqus
]]>