Permutations & Combinations for large inputs
|
05-26-2015, 05:14 PM
(This post was last modified: 05-26-2015 10:45 PM by Dieter.)
Post: #6
|
|||
|
|||
RE: Permutations & Combinations for large inputs
(05-26-2015 12:22 PM)Werner Wrote: Common pitfalls for a COMB routine: That's the way I do it in higher-level programming languages where count-up loops are much more relaxed than on calculators like the HP41. ;-) However, small input like in your example is evaluated directly via factorials in the program I posted. Since the program calculates n!/(n–r)! first (which always is an integer) the results should be exact here. (05-26-2015 12:22 PM)Werner Wrote: - C(335,167) overflows while the result is < 1e100 OK. But at least the version I posted correctly retuns C(336, 168) as 6,0887 E+99. #-) (05-26-2015 12:22 PM)Werner Wrote: solution: calculate 0.001*n/1*(n-1)/2*(n-2)/3... *1000 That's an interesting approach. (05-26-2015 12:22 PM)Werner Wrote: - C(n,0) = 1 That's what my version implements as well. However, the C(n, 0) case has to be handled separately. I now posted an update. (05-26-2015 12:22 PM)Werner Wrote: The following routine avoids these, but may return slightly inaccurate Yes, you can't expect 10-digit accuracy with merely 10-digit precision. Dieter |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)