Riordan numbers: Difference between revisions

Content added Content deleted
(Add Scala implementation)
(Add Mathematica/Wolfram Language implementation)
Line 994: Line 994:
834,086,421 2,358,641,376 6,684,761,125 18,985,057,351
834,086,421 2,358,641,376 6,684,761,125 18,985,057,351
54,022,715,451 154,000,562,758 439,742,222,071 1,257,643,249,140
54,022,715,451 154,000,562,758 439,742,222,071 1,257,643,249,140
</pre>

=={{header|Mathematica}}/{{header|Wolfram Language}}==
<syntaxhighlight lang="Mathematica">
Riordan[N_] :=
Module[{a = {1, 0, 1}},
Do[AppendTo[a, ((n - 1) (2 a[[n]] + 3 a[[n - 1]])/(n + 1))], {n, 3,
N}];
a]

rios = Riordan[10000];

Do[Print[ToString@NumberForm[rios[[i]], DigitBlock -> 3]], {i, 32}]

Print["The 1,000th Riordan number has ", IntegerLength[rios[[1000]]],
" digits."];
Print["The 10,000th Riordan number has ",
IntegerLength[rios[[10000]]], " digits."];
</syntaxhighlight>
{{out}}
<pre>
1
0
1
1
3
6
15
36
91
232
603
1,585
4,213
11,298
30,537
83,097
227,475
625,992
1,730,787
4,805,595
13,393,689
37,458,330
105,089,229
295,673,994
834,086,421
2,358,641,376
6,684,761,125
18,985,057,351
54,022,715,451
154,000,562,758
439,742,222,071
1,257,643,249,140
The 1,000th Riordan number has 472 digits.
The 10,000th Riordan number has 4765 digits.

</pre>
</pre>