File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change
1
+ = begin pod
2
+
3
+ = head1 Binomial Coefficient
4
+
5
+ Number of ways to choose P objects among N. It's also the coefficient of the
6
+ monome of degree P in the expansion of (1 + X)^N, thus the name.
7
+
8
+
9
+ N (N-P+1)*(N-P)*...*N
10
+ ( ) = ∑ -------------------
11
+ P 1*2*...*P
12
+
13
+
14
+ = head1 More
15
+
16
+ L < http://rosettacode.org/wiki/Evaluate_binomial_coefficients#Perl_6 >
17
+
18
+ = head1 Notable features used
19
+
20
+ = item infix sub definition
21
+ = item reduction meta-operator
22
+ = item self-declared parameters
23
+ = item range operator with first value excluded
24
+ = item Zip metaoperator with an infinite liste on the right side
25
+ = item use of rational numbers as a default
26
+
27
+ = end pod
28
+
29
+ sub infix :<choose > { [* ] $ ^ n - $ ^ p ^.. $ n Z / 1 .. * }
30
+
31
+ say 5 choose 3 ;
You can’t perform that action at this time.
0 commit comments