Evaluate binomial coefficients: Difference between revisions

→‎{{header|Perl 6}}: div can actually be used here to solve the type issue
(→‎{{header|Perl 6}}: div can actually be used here to solve the type issue)
Line 1,333:
 
=={{header|Perl 6}}==
<lang perl6>sub infix:<choose> { [*] ($^n ... 0) Z/Zdiv 1 .. $^p }
say 5 choose 3;</lang>
{{out}}
<pre>10</pre>
 
One drawback of this method is that it returns a Rat, not an Int. If we really worry about it, we can enforce the conversion:
<lang perl6>sub infix:<choose> { ([*] ($^n ... 0) Z/ 1 .. $^p).Int }</lang>
 
=={{header|PL/I}}==
1,934

edits