Catalan numbers/Pascal's triangle: Difference between revisions

(Added Mathematica)
Line 1:
{{task}}
The task is to print out the first 15 Catalan numbers by extracting them from Pascal's triangle, see [http://milan.milanovic.org/math/english/fibo/fibo4.html Catalan Numbers and the Pascal Triangle].
 
=={{header|Ada}}==
 
<lang Ada>with Ada.Text_IO;
 
procedure Catalan is
type Pos_Arr is array(Positive range <>) of Positive;
function Pascal(R: Positive) return Pos_Arr is -- Pascal triangle, R'th row
A: Pos_Arr(1 .. R);
begin
for Row in 1 .. R loop
A(Row) := 1;
for J in reverse 2 .. Row-1 loop
A(J) := A(J) + A(J-1);
end loop;
end loop;
return A;
end Pascal;
begin
for I in 1 .. 15 loop
declare
Pas: Pos_Arr := Pascal(2*I+1); -- row 2*I+1 of Pascal triangle
begin
Ada.Text_IO.Put(Integer'Image(Pas(I+1)-Pas(I+2)));
end;
end loop;
end Catalan;</lang>
 
 
=={{header|AutoHotkey}}==
Anonymous user