11 lines
345 B
Text
11 lines
345 B
Text
do -- print some catalan numbers
|
|
local function printCatalan( n : number, cn : number )
|
|
print( string.format( "%3d: %d", n, cn ) )
|
|
end
|
|
local Cprev = 1 -- C0
|
|
printCatalan( 0, Cprev )
|
|
for n = 1, 15 do
|
|
Cprev = math.round( ( ( ( 4 * n ) - 2 ) / ( n + 1 ) ) * Cprev )
|
|
printCatalan( n, Cprev )
|
|
end
|
|
end
|