Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[rosalind] INDC
  • Loading branch information
grondilu committed Dec 7, 2012
1 parent 343cb99 commit 5a73069
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions rosalind/indc-grondilu.pl
@@ -0,0 +1,16 @@
use v6;

my $n = $*IN.get.Int;

sub postfix:<!>($n) { [*] 1 .. $n }
sub C($n, $k) {
state %cache;
%cache{$n}{$k} //=
$k == 1 ?? $n !! C($n, $k-1)*($n-$k+1) div $k
}

say gather for 1 .. 2*$n -> $k {
take .log / log 10 given 1/2**(2*$n) * [+] map { C 2*$n, $_ }, $k .. 2*$n;
}

# vim: ft=perl6

0 comments on commit 5a73069

Please sign in to comment.