Catalan numbers/Pascal's triangle: Difference between revisions
→{{header|jq}}: emphasize alternative computation
m (→{{header|REXX}}: added a section header comment about arbitrary numbers.) |
(→{{header|jq}}: emphasize alternative computation) |
||
Line 166:
}:@:(}.@:((<0 1)&|:) - }:@:((<0 1)&|:@:(2&|.)))@:(i. +/\@]^:[ #&1)@:(2&+)</lang>
=={{header|jq}}==
The first identity (C(2n,n) - C(2n, n-1)) given in the reference is used in accordance with the task description,
''Warning'': jq uses IEEE 754 64-bit arithmetic,
Line 176 ⟶ 175:
end;
# Direct (naive) computation using two numbers in Pascal's triangle:
def catalan_by_pascal: . as $n | binomial(2*$n; $n) - binomial(2*$n; $n-1);</lang>
|