Files
SnowLuma/.pnpm-store/v11/files/31/50262922c71f6f9e07d02b4f0937552dc1c4b377407bf19a8c76485066bf66b861365b3ace58477f522dc92df49949a0290e9012055d3a7a434b5765fa4454
T
TanTan 2a69b23b47
Dev Build / cleanup (push) Canceled after 0s
Dev Build / typecheck (push) Canceled after 0s
Dev Build / build (linux-arm64, ubuntu-24.04-arm, linux-arm64) (push) Canceled after 0s
Dev Build / build (linux-x64, ubuntu-latest, linux-x64) (push) Canceled after 0s
Dev Build / build (win-x64, windows-latest, win32-x64) (push) Canceled after 0s
Dev Build / dispatch-dev-docker (push) Canceled after 0s
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

38 lines
742 B
Plaintext

const LOG10 = Math.log(10);
const LOG2 = Math.log(2);
var utils = {
// binomial coefficients
// src: http://blog.plover.com/math/choose.html
nCk(n, k) {
let count = n;
if (k > count) {
return 0;
}
if (k === 0) {
return 1;
}
let coEff = 1;
for (let i = 1; i <= k; i += 1) {
coEff *= count;
coEff /= i;
count -= 1;
}
return coEff;
},
log10(n) {
if (n === 0) return 0;
return Math.log(n) / LOG10; // IE doesn't support Math.log10 :(
},
log2(n) {
return Math.log(n) / LOG2;
},
factorial(num) {
let rval = 1;
for (let i = 2; i <= num; i += 1) rval *= i;
return rval;
}
};
export { utils as default };
//# sourceMappingURL=utils.mjs.map