染色体的自由组合
作者:L. Grondin
http://rosalind.info/problems/indc/
示例输入
5
示例输出
0.000 -0.004 -0.024 -0.082 -0.206 -0.424 -0.765 -1.262 -1.969 -3.010
源代码: indc-grondilu.pl
use v6; my $n = 5; sub C($n, $k) { state %cache; %cache{$n}{$k} //= $k == 1 ?? $n !! C($n, $k-1)*($n-$k+1) div $k; } my @results = gather for 1 .. 2*$n -> $k { take .log / log 10 given 1/2**(2*$n) * [+] map { C 2*$n, $_ }, $k .. 2*$n; } say @results.fmt("%.3f");