Riordan numbers: Difference between revisions

Content added Content deleted
(Added Algol 68)
(Added PL/I)
Line 137: Line 137:
#":(1e4-1){riordanext^:(1e4) x:1 0
#":(1e4-1){riordanext^:(1e4) x:1 0
4765</lang>
4765</lang>
=={{header|PL/I}}==
<lang pli>showRiordan: procedure options( main ); /* find some Riordan numbers */

%replace maxRiordan by 32;

/* sets a to the first n riordan numbers a must have bounds 1 : n */
/* so the first number has index 1, not 0 */
riordan: procedure( n, a );
declare n binary( 15 )fixed;
declare a ( maxRiordan )decimal( 14 );

declare ( r2, r1, ri, i ) decimal( 14 );

if n >= 1 then do;
r2 = 1;
a( 1 ) = r2;
if n >= 2 then do;
r1 = 0;
a( 2 ) = r1;
do i = 2 to n;
ri = ( ( i - 1 )
* ( ( 2 * r1 )
+ ( 3 * r2 )
)
)
/ ( i + 1 );
a( i + 1 ) = ri;
r2 = r1;
r1 = ri;
end;
end;
end;
end riordan ;

declare r ( maxRiordan )decimal( 14 ), i binary( 15 )fixed;

call riordan( maxRiordan, r );
do i = 1 to maxRiordan;
put list( ' ', r( i ) );
if mod( i, 4 ) = 0 then put skip;
end;

end showRiordan;</lang>
{{out}}
<pre>
1 0 1 1
3 6 15 36
91 232 603 1585
4213 11298 30537 83097
227475 625992 1730787 4805595
13393689 37458330 105089229 295673994
834086421 2358641376 6684761125 18985057351
54022715451 154000562758 439742222071 1257643249140
</pre>

=={{header|Phix}}==
=={{header|Phix}}==
<!--<lang Phix>(phixonline)-->
<!--<lang Phix>(phixonline)-->
Line 173: Line 228:
The ten thousandth: 19927418577260688844...71395322020211157137 (4,765 digits)
The ten thousandth: 19927418577260688844...71395322020211157137 (4,765 digits)
</pre>
</pre>

=={{header|Raku}}==
=={{header|Raku}}==
<lang perl6>use Lingua::EN::Numbers;
<lang perl6>use Lingua::EN::Numbers;