Files
SnowLuma/.pnpm-store/v11/files/e0/cd07a78141879a94bfeefbcb5d80d1e00c68e1d5afdba4681f0c3efc7851eacc825f77e0ed985123198c0172b6d5deaf6d8b78483118a54c36e3299b57f3f6
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) Skipped
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

40 lines
752 B
Plaintext

'use strict';
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;
}
};
module.exports = utils;
//# sourceMappingURL=utils.cjs.map