in reply to Calculating the number of possible matches with N mismatches for DNA? [Solved!]

You can simplify the calculation to

sub NwithM { my $f = 4-1; my( $L, $M ) = @_; my $T=1; my $tmp = 1; for my $m ( 1 .. $M ) { $tmp *= ($L-$m+1)/$m*$f; $T += $tmp; } return $T; }
  • Comment on Re: Calculating the number of possible matches with N mismatches for DNA? [Solved!]
  • Download Code

Replies are listed 'Best First'.
Re^2: Calculating the number of possible matches with N mismatches for DNA? [Solved!]
by BrowserUk (Patriarch) on May 27, 2015 at 07:35 UTC

    Accumulating partial solutions for input to later iterations. I doubt I would ever have seen that. Very nice. Thank you.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
    In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked