Factorial in BCPL
Example for versions
64-bit BCPL Cintcode System (1 Nov 2006)
This example uses recursive factorial definition. Calculating 15! and larger results in math overflow, thus the result ends like this:
12! = 479001600
13! = 6227020800
14! = 87178291200
15! = 18000
16! = 000
GET "libhdr"
LET start() = VALOF
{ FOR i = 0 TO 16 DO writef("%n! = %n*n", i, factorial(i))
RESULTIS 0
}
AND factorial(n) = n=0 -> 1, n*factorial(n-1)
Comments
]]>blog comments powered by Disqus
]]>