学習環境
- Surface 3 (4G LTE)、Surface 3 タイプ カバー、Surface ペン(端末)
- Windows 10 Pro (OS)
- 数式入力ソフト(TeX, MathML): MathType
- MathML対応ブラウザ: Firefox、Safari
- MathML非対応ブラウザ(Internet Explorer, Google Chrome...)用JavaScript Library: MathJax
数学読本〈4〉数列の極限,順列/順列・組合せ/確率/関数の極限と微分法(松坂 和夫(著)、岩波書店)の第15章(「場合の数」 を数える - 順列・組合せ)、15.2(組合せ)、組合せの公式、問13、14、15、16、17、18.を取り組んでみる。
コード(Emacs)
HTML5
<button id="run0">run</button> <button id="clear0">clear</button> <pre id="output0"></pre> <script src="sample13.js"></script>
JavaScript
let btn0 = document.querySelector('#run0'),
btn1 = document.querySelector('#clear0'),
pre0 = document.querySelector('#output0');
let factorial = (n) => {
return n <= 1 ? 1 : n * factorial(n - 1);
};
let combination = (n, r) => {
return factorial(n) / (factorial(r) * factorial(n - r));
};
let output = () => {
pre0.textContent =
'13.\n' +
`${combination(7, 3) * combination(5, 2)}\n` +
'14-1.\n' +
`${combination(9, 4) * combination(5, 3) * combination(2, 2)}\n` +
'14-2.\n' +
`${combination(9, 3) * combination(6, 3) * combination(3, 3)}\n` +
'14-3.\n' +
`${1680 / factorial(3)}\n` +
'15.\n' +
`${combination(18, 6) - combination(12, 6) * 3}\n` +
'17.\n' +
`${combination(5, 2) * 5 + combination(5, 1) * combination(5, 2) + combination(5, 3)}\n` +
'18.\n' +
`${combination(11, 7)}\n`;
};
btn0.onclick = output;
btn1.onclick = () => {
pre0.textContent = '';
};
output();
0 コメント:
コメントを投稿