Processing math: 100%

2017年4月7日金曜日

学習環境

数学読本〈4〉数列の極限,順列/順列・組合せ/確率/関数の極限と微分法(松坂 和夫(著)、岩波書店)の第15章(「場合の数」 を数える - 順列・組合せ)、15.2(組合せ)、組合せの公式、問13、14、15、16、17、18.を取り組んでみる。


  1. (73)·(52)=35·10=350

    1. (94)·(53)·(22)=1260

    2. (93)·(63)·(33)=84·20=1680

    3. 16803!=280

  2. (186)(126)·3=17·2·3·14·1311·2·3·2·7·3=6(17·14·1311·2·7·3)=6·14(17·1311·3)=84(22133)=84·188=15792

  3. (n2)n=n(n1)2n2=n(n3)2

  4. (52)·5+(51)·(52)+(53)=11·10=110

  5. (117)=(114)=11·10·3=330

コード(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();
13.
350
14-1.
1260
14-2.
1680
14-3.
280
15.
15792
17.
110
18.
330

0 コメント:

コメントを投稿