Catalan numbers: Difference between revisions
Content added Content deleted
No edit summary |
m (Updated Julia) |
||
Line 1,470: | Line 1,470: | ||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
From the Catalan package, returns the n-th Catalan number |
|||
<lang julia>function catalan( |
<lang julia>function catalan(bn::Integer) |
||
⚫ | |||
if bn < 0 |
|||
throw(DomainError()) |
|||
else |
|||
n = BigInt(bn) |
|||
end |
|||
⚫ | |||
end</lang> |
end</lang> |
||
{{out}} |
{{out}} |
||
< |
<pre>julia> for n = 1:15 println(catalan(n)) end |
||
1 |
1 |
||
2 |
2 |
||
5 |
5 |
||
14 |
14 |
||
42 |
42 |
||
132 |
132 |
||
429 |
429 |
||
1430 |
1430 |
||
4862 |
4862 |
||
16796 |
16796 |
||
58786 |
58786 |
||
208012 |
208012 |
||
742900 |
742900 |
||
2674440 |
|||
2.67444e6 |
|||
9694845</pre> |
|||
9.694845e6</lang> |
|||
=={{header|K}}== |
=={{header|K}}== |