math.permutations関数の引数に任意の数値を渡すと、その階乗の値が返されます。
また、第二引数にサブセットの値を渡すと、そこまでの計算結果が返されます。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | < html > < head > < script type = text /javascript src = "https://cdnjs.cloudflare.com/ajax/libs/mathjs/9.4.4/math.min.js" ></ script > </ head > < body > < script > var ret1 = math.permutations(6); console.log(ret1); var ret2 = math.permutations(6, 3); console.log(ret2); </ script > </ body > </ html > |
リンク
math.js | an extensive math library for JavaScript and Node.js
https://mathjs.org/docs/reference/functions/permutations.html