Catalan numbers/Pascal's triangle: Difference between revisions

(Updated D entry)
Line 4:
=={{header|Ada}}==
 
Uses package Pascal from the Pascal triangle solution[[http://rosettacode.org/wiki/Pascal%27s_triangle#Ada]]
<lang Ada>with Ada.Text_IO;
 
<lang Ada>with Ada.Text_IO, Pascal;
 
procedure Catalan is
Last: Positive := 17;
type Pos_Arr is array(Positive range <>) of Positive;
Row: Pascal.Row := Pascal.First_Row(2*Last+1);
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 .. 15Last loop
Row := Pascal.Next_Row(Row);
declare
Pas: Pos_Arr Row := Pascal.Next_Row(2*I+1Row); -- row 2*I+1 of Pascal triangle
Ada.Text_IO.Put(Integer'Image(PasRow(I+1)-PasRow(I+2)));
begin
Ada.Text_IO.Put(Integer'Image(Pas(I+1)-Pas(I+2)));
end;
end loop;
end Catalan;</lang>
 
{{out}}
 
<pre>1 2 5 14 42 132 429 1430 4862 16796 58786 208012 742900 2674440 9694845 35357670 129644790</pre>
 
=={{header|AutoHotkey}}==
Anonymous user