学習環境
- Surface 3 (4G LTE)、Surface 3 タイプ カバー、Surface ペン(端末)
- Windows 10 Pro (OS)
- Nebo(Windows アプリ)
- iPad Pro + Apple Pencil
- MyScript Nebo(iPad アプリ)
- 参考書籍
代数系入門 (松坂 和夫(著)、岩波書店)の第1章(整数)、6(同値関係、合同式)、問題10.を取り組んでみる。
 - よって、求める余りは75。 
コード(Emacs)
Python 3
#!/usr/bin/env python3
def mod(a, b, m):
    return (a - b) % m == 0
print(mod((2 ** 100 - 1) ** 99, 75, 100))
入出力結果(Terminal, Jupyter(IPython))
$ ./sample10.py True $
HTML5
<pre id="output0"></pre> <button id="run0">run</button> <button id="clear0">clear</button> <script src="sample10.js"></script>
JavaScript
let pre0 = document.querySelector('#output0'),
    run0 = document.querySelector('#run0'),
    clear0 = document.querySelector('#clear0'),
    p = (text) => pre0.textContent += text + '\n',
    clear = () => pre0.textContent = '',
    mod = (a, b, m) => (a - b) % m === 0,
    output = () => {        
        p(mod((2 ** 100 - 1) ** 99, 75, 100));
        p((2 ** 100 - 1) ** 99);
    };
run0.onclick = output;
clear0.onclick = clear;
output();
						 
0 コメント:
コメントを投稿