p,qの互除法とは，p,qを二辺とする長方形を書き，
できるだけ少ない個数の正方形でこれを
埋め尽くす作業と似ています．
スライダを動かして確認してみましょう．

n = 3 (slider from 1 to 8, step 1)
n_2 = If(n ≟ 1, 48, If[n ≟ 2, 27, If[n < 7, 6, 3]])
n_1 = If(n < 4, 21, If[n ≟ 4, 15, If[n ≟ 5, 9, 3]])
B_7 = If(n > 7, (0, 0), (100, 100))
A_7 = If(n > 7, (0, 3), (100, 100))
多角形1, a, b, c, d, C, D = Polygon(A_7, B_7, 4)
A_6 = If(n > 6, (0, 6), (100, 100))
B_6 = If(n > 6, (0, 3), (100, 100))
多角形2, a_6, b_6, e, f, A, B = Polygon(A_6, B_6, 4)
A_5 = If(n > 5, (3, 6), (100, 100))
B_5 = If(n > 5, (3, 0), (100, 100))
多角形3, a_5, b_5, g, h, E, F = Polygon(A_5, B_5, 4)
A_4 = If(n > 4, (9, 6), (100, 100))
A_3 = If(n > 3, (15, 6), (100, 100))
A_2 = If(n > 2, (0, 27), (100, 100))
A_1 = If(n > 1, (0, 48), (100, 100))
B_4 = If(n > 4, (9, 0), (100, 100))
B_3 = If(n > 3, (15, 0), (100, 100))
B_2 = If(n > 2, (0, 6), (100, 100))
B_1 = If(n > 1, (0, 27), (100, 100))
多角形4, a_1, b_1, i, j, G, H = Polygon(A_1, B_1, 4)
多角形5, a_2, b_2, k, l, I, J = Polygon(A_2, B_2, 4)
多角形6, a_3, b_3, m, p, K, L = Polygon(A_3, B_3, 4)
多角形7, a_4, b_4, q, r, M, N = Polygon(A_4, B_4, 4)
O = (0, 0)
P: (n_1, 0)
R: (0, n_2)
Q: (n_1, n_2)
多角形8, o, p_1, q_1, r_1 = Polygon(O, P, Q, R)
テキスト1: "(p,q)=(" + n_1 + "," + n_2 + ")"