Closed dsvictor94 closed 4 years ago
It's because C
is defined as P(m, n) / P(n, n)
and P(25,20)
returns 1.2926008369442487e+23
, too big for Number
to keep its integral value (129,260,083,694,425,000,000,000
). Time to add BigInt
support?
Version 0.6.0 (https://github.com/dankogai/js-combinatorics/commit/10374fc4e3f77fc05ee7eb765263adf311206885) now supports BigInt.
> Combinatorics.factorial(100)
9.332621544394418e+157
> Combinatorics.factorial(100n)
93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000n
>
Combinatorics.C(25, 20) = 53129.99999999999
Expected: 53130
https://jsfiddle.net/27sf94k1/