The stupid question is the question not asked PerlMonks

### Re^2: Algorithm for cancelling common factors between two lists of multiplicands

by BrowserUk (Patriarch)
 on Aug 09, 2005 at 09:06 UTC Need Help??

There are better ways to compute factorial quotients without overflow or loss of precision.

So, now I've got my "schoolboy approach" working, care to point me at the methods clever people would use?

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.

Replies are listed 'Best First'.
Re^3: Algorithm for cancelling common factors between two lists of multiplicands
by QM (Parson) on Aug 09, 2005 at 15:19 UTC
So, now I've got my "schoolboy approach" working, care to point me at the methods clever people would use?
I was too lazy to look before, but now that I have, I was a bit off. On the other hand, I snuck in something similar in step 5 anyway. Here's what I remembered when I said that:

In QOTW #2 MJD considers the n_choose_k function that computes:

```sub n_choose_k {
my (\$n, \$k) = @_;
# f(\$n) = \$n!
return f(\$n)/f(\$k)/f(\$n-\$k);
}
He notes that the intermediate values are very large, even though the final result is not. He submits this replacement:
```sub n_choose_k {
my (\$n, \$k) = @_;
my \$t = 1;
for my \$i (1 .. \$k) {
\$t *= \$n - \$k + \$i;
\$t /= \$i;
}
return \$t;
}
and he notes:
\$t here is always an integer, and never gets bigger than necessary.
For your formula, this only applies to a small portion of the terms. You may be better off just ignoring MJD's improvement and proceeding as I outlined before.

-QM
--
Quantum Mechanics: The dreams stuff is made of

Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://482145]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2024-03-01 14:01 GMT
Voting Booth?
My favourite way to spend a leap day ...

Results (28 votes). Check out past polls.