Combinations and permutations: Difference between revisions

m
→‎{{header|Raku}}: Fix comments: Perl 6 --> Raku
m (→‎{{header|Phix}}: Fix comment: Perl 6 --> Raku)
m (→‎{{header|Raku}}: Fix comments: Perl 6 --> Raku)
Line 1,816:
=={{header|Raku}}==
(formerly Perl 6)
Perl 6Raku can't compute arbitrary large floating point values, thus we will use logarithms, as is often needed when dealing with combinations. We'll also use a Stirling method to approximate <math>\ln(n!)</math>:
 
<math>\ln n! \approx
\frac{1}{2}\ln(2\pi n) + n\ln\left(\frac{n}{e} + \frac{1}{12 e n}\right)</math>
 
Notice that Perl6Raku can process arbitrary long integers, though. So it's not clear whether using floating points is useful in this case.
 
<lang perl6>multi P($n, $k) { [*] $n - $k + 1 .. $n }
2,392

edits