19 lines
393 B
Text
19 lines
393 B
Text
catalan: procedure options (main); /* 23 February 2012 */
|
|
declare (i, n) fixed;
|
|
|
|
put skip list ('How many catalan numbers do you want?');
|
|
get list (n);
|
|
|
|
do i = 0 to n;
|
|
put skip list (c(i));
|
|
end;
|
|
|
|
c: procedure (n) recursive returns (fixed decimal (15));
|
|
declare n fixed;
|
|
|
|
if n <= 1 then return (1);
|
|
|
|
return ( 2*(2*n-1) * c(n-1) / (n + 1) );
|
|
end c;
|
|
|
|
end catalan;
|