extra-math 1.2.5 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +7 -3
- package/index.js +4 -4
- package/index.mjs +4 -4
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -22,29 +22,33 @@ declare function modp(x: number, y: number): number;
|
|
|
22
22
|
/**
|
|
23
23
|
* Find the greatest common divisor of numbers.
|
|
24
24
|
* @param xs a list of numbers
|
|
25
|
+
* @returns gcd(x₁, x₂, ...)
|
|
25
26
|
*/
|
|
26
27
|
declare function gcd(...xs: number[]): number;
|
|
27
28
|
/**
|
|
28
29
|
* Find the least common multiple of numbers.
|
|
29
30
|
* @param xs a list of numbers
|
|
31
|
+
* @returns lcm(x₁, x₂, ...)
|
|
30
32
|
*/
|
|
31
33
|
declare function lcm(...xs: number[]): number;
|
|
32
34
|
/**
|
|
33
35
|
* Find the factorial of a number.
|
|
34
|
-
* @param
|
|
36
|
+
* @param n a number
|
|
35
37
|
* @param k denominator factorial [0]
|
|
36
|
-
* @returns k=0:
|
|
38
|
+
* @returns P(n, k); k=0: n!, k>0: n!/k!
|
|
37
39
|
*/
|
|
38
|
-
declare function factorial(
|
|
40
|
+
declare function factorial(n: number, k?: number): number;
|
|
39
41
|
/**
|
|
40
42
|
* Find the number of ways to choose k elements from a set of n elements.
|
|
41
43
|
* @param n elements in source set
|
|
42
44
|
* @param k elements in choose set
|
|
45
|
+
* @returns C(n, k)
|
|
43
46
|
*/
|
|
44
47
|
declare function binomial(n: number, k: number): number;
|
|
45
48
|
/**
|
|
46
49
|
* Find the number of ways to put n objects in m bins (n=sum(kᵢ)).
|
|
47
50
|
* @param ks objects per bin (kᵢ)
|
|
51
|
+
* @returns n!/(k₁!k₂!...)
|
|
48
52
|
*/
|
|
49
53
|
declare function multinomial(...ks: number[]): number;
|
|
50
54
|
/**
|
package/index.js
CHANGED
|
@@ -28,11 +28,11 @@ function gcd(...xs) {
|
|
|
28
28
|
function lcm(...xs) {
|
|
29
29
|
return product(...xs) / gcd(...xs);
|
|
30
30
|
}
|
|
31
|
-
function factorial(
|
|
32
|
-
if (
|
|
31
|
+
function factorial(n, k = 0) {
|
|
32
|
+
if (n < 0)
|
|
33
33
|
return 0;
|
|
34
|
-
for (var i = k + 1, a = 1; i <=
|
|
35
|
-
a *=
|
|
34
|
+
for (var i = k + 1, a = 1; i <= n; i++)
|
|
35
|
+
a *= n;
|
|
36
36
|
return a;
|
|
37
37
|
}
|
|
38
38
|
function binomial(n, k) {
|
package/index.mjs
CHANGED
|
@@ -24,11 +24,11 @@ function gcd(...xs) {
|
|
|
24
24
|
function lcm(...xs) {
|
|
25
25
|
return product(...xs) / gcd(...xs);
|
|
26
26
|
}
|
|
27
|
-
function factorial(
|
|
28
|
-
if (
|
|
27
|
+
function factorial(n, k = 0) {
|
|
28
|
+
if (n < 0)
|
|
29
29
|
return 0;
|
|
30
|
-
for (var i = k + 1, a = 1; i <=
|
|
31
|
-
a *=
|
|
30
|
+
for (var i = k + 1, a = 1; i <= n; i++)
|
|
31
|
+
a *= n;
|
|
32
32
|
return a;
|
|
33
33
|
}
|
|
34
34
|
function binomial(n, k) {
|