Pascal's triangle: Difference between revisions
m
→explanation: add indents
No edit summary |
m (→explanation: add indents) |
||
Line 484:
Of course, the triangle itself is simply the table of number-of-combinations, for the first N non-negative integers.
That is, [[wp:Combination|C(n,k)]] for all <tt>n,k ∈ [0 .. n)</tt>. J's notation for <tt>C(n,k)</tt> is <
So, for example, the number of ways to choose a poker hand (5 cards from the deck of 52):
Line 490:
2598960</lang>
So <
So, for example, here's the multiplication table you had to memorize in first grade:
<lang j> */~@i. 10
and here's the addition table for 0 to 4
<lang j> +/~@i. 4
0 1 2 3
1 2 3 4
Line 512:
3 4 5 6</lang>
Similarly, <
<lang j> !/~@i. 5
1 1 1 1 1
0 1 2 3 4
Line 521:
Of course, to format it nicely, you need to do a little more work:
<lang j> ([:'0'&=`(,:&' ')} -@|. |."_1 [: ":@|: !/~)@i. 5
1
1 1
|