学習環境
- Surface 3 (4G LTE)、Surface 3 タイプ カバー、Surface ペン(端末)
- Windows 10 Pro (OS)
- Nebo(Windows アプリ)
- iPad Pro + Apple Pencil
- MyScript Nebo(iPad アプリ)
- 参考書籍
代数系入門 (松坂 和夫(著)、岩波書店)の第1章(整数)、6(同値関係、合同式)、問題2.を取り組んでみる。
問題の仮定より、
よって
コード(Emacs)
Python 3
#!/usr/bin/env python3
import random
def mod(a, b, m):
return (a - b) % m == 0
m = 11
c = 13
for _ in range(10):
a = random.randrange(100)
b = random.randrange(100)
for t in [mod(a * c, b * c, m), mod(a, b, m)]:
print(t)
print()
入出力結果(Terminal, Jupyter(IPython))
$ ./sample2.py False False True True False False False False False False False False False False False False True True False False $
HTML5
<pre id="output0"></pre> <input id="a0" type="number" step="1" value="26">・ <input id="c0" type="number" step="1" value="11"> ≡ <input id="b0" type="number" step="1" value="39">・ <span id="c1"></span> (mod <input id="m0" type="number" step="1" value="13">) <br> <button id="run0">run</button> <button id="clear0">clear</button> <script src="sample2.js"></script>
JavaScript
let pre0 = document.querySelector('#output0'),
run0 = document.querySelector('#run0'),
clear0 = document.querySelector('#clear0'),
input_a0 = document.querySelector('#a0'),
input_b0 = document.querySelector('#b0'),
input_c0 = document.querySelector('#c0'),
input_m0 = document.querySelector('#m0'),
span_c1 = document.querySelector('#c1'),
inputs = [input_a0, input_b0, input_c0, input_m0],
range = (n) => {
let result = [];
for (let i = 0; i < n; i += 1) {
result.push(i);
}
return result;
},
p = (text) => pre0.textContent += text + '\n',
clear = () => pre0.textContent = '',
output = () => {
let a0 = parseInt(input_a0.value, 10),
b0 = parseInt(input_b0.value, 10),
c0 = parseInt(input_c0.value, 10),
m0 = parseInt(input_m0.value, 10);
span_c1.textContent = c0;
p(`a = ${a0}, b = ${b0}, m = ${m0}`);
p((a0 * c0 - b0 * c0) % m0 == 0);
p((a0 - b0) % m0 == 0);
};
run0.onclick = output;
clear0.onclick = clear;
inputs.forEach((input) => input.onchange = output);
output();
・
≡
・
(mod )
Zenback読み込み中です。
0 コメント:
コメントを投稿
この投稿へのリンク
リンクを作成
Comments on Google+: