Visualization of GCD and the Euclidean Algorithm

Visualization of GCD and the Euclidean Algorithm
Loading the math board and drawing, please wait…
2013-04-24 10:35
This example visually demonstrates the computation of the Greatest Common Divisor (GCD) of two integers using the Euclidean algorithm. Utilizing commands like Mod, Div, and Sequence, it dynamically illustrates the iterative steps in a spreadsheet. It also employs polygons to provide a geometric visualization of the algebraic process through rectangle subdivision, aiding in the understanding of this fundamental number theory algorithm. Students can input any two positive integers and observe as the applet breaks down each step of the Euclidean algorithm in real time. The spreadsheet displays the successive quotients and remainders, clearly showing how each remainder becomes the divisor in the next iteration until the remainder reaches zero. The final non-zero remainder is highlighted as the GCD of the original pair. On the geometric side, the applet transforms these calculations into a visual rectangle-tiling construction. A rectangle with dimensions equal to the two input numbers is progressively subdivided into squares, where each square's side length corresponds to the current remainder. This elegant geometric interpretation makes the abstract division process tangible: each tiling step mirrors a division operation, and the smallest square that perfectly fills the remaining region represents the GCD. Learners can see directly why the last square's side length is the largest integer that divides both original numbers. Interactive sliders allow users to adjust the input values and watch the entire process update instantly. The combination of algebraic computation in the spreadsheet and geometric representation through polygons reinforces the conceptual connection between division with remainders and area partitioning. This dual representation helps students build a deeper intuition for why the Euclidean algorithm works, making it an effective teaching tool for courses in number theory, discrete mathematics, or introductory computer science.

GeoGebra Commands & Parameters

  1. Intersect(xAxis, yAxis) → O
  2. Min(a, b) → B1
  3. Max(a, b) → A1
  4. Div(A1, B1) → C1
  5. Mod(A1, B1) → D1
  6. If(D1 ≠ 0, B1, 0) → A2
  7. If(D1 ≠ 0, D1, 0) → B2
  8. If(D1 ≠ 0, Div[A2, B2], 0) → C2
  9. If(D1 ≠ 0, Mod[A2, B2], 0) → D2
  10. If(D2 ≠ 0, B2, 0) → A3
  11. If(D2 ≠ 0, D2, 0) → B3
  12. If(D2 ≠ 0, Div[A3, B3], 0) → C3
  13. If(D2 ≠ 0, Mod[A3, B3], 0) → D3
  14. If(D3 ≠ 0, B3, 0) → A4
  15. If(D3 ≠ 0, D3, 0) → B4
  16. If(D3 ≠ 0, Div[A4, B4], 0) → C4
  17. If(D3 ≠ 0, Mod[A4, B4], 0) → D4
  18. If(D4 ≠ 0, B4, 0) → A5
  19. If(D4 ≠ 0, D4, 0) → B5
  20. If(D4 ≠ 0, Div[A5, B5], 0) → C5
  21. If(D4 ≠ 0, Mod[A5, B5], 0) → D5
  22. If(D5 ≠ 0, B5, 0) → A6
  23. If(D5 ≠ 0, D5, 0) → B6
  24. If(D5 ≠ 0, Div[A6, B6], 0) → C6
  25. If(D5 ≠ 0, Mod[A6, B6], 0) → D6
  26. If(D6 ≠ 0, B6, 0) → A7
  27. If(D6 ≠ 0, D6, 0) → B7
  28. If(D6 ≠ 0, Div[A7, B7], 0) → C7
  29. If(D6 ≠ 0, Mod[A7, B7], 0) → D7
  30. If(D7 ≠ 0, B7, 0) → A8
  31. If(D7 ≠ 0, D7, 0) → B8
  32. If(D7 ≠ 0, Div[A8, B8], 0) → C8
  33. If(D7 ≠ 0, Mod[A8, B8], 0) → D8
  34. If(D8 ≠ 0, B8, 0) → A9
  35. If(D8 ≠ 0, D8, 0) → B9
  36. If(D8 ≠ 0, Div[A9, B9], 0) → C9
  37. If(D8 ≠ 0, Mod[A9, B9], 0) → D9
  38. If(D9 ≠ 0, B9, 0) → A10
  39. If(D9 ≠ 0, D9, 0) → B10
  40. If(D9 ≠ 0, Div[A10, B10], 0) → C10
  41. If(D9 ≠ 0, Mod[A10, B10], 0) → D10
  42. If(D10 ≠ 0, B10, 0) → A11
  43. If(D10 ≠ 0, D10, 0) → B11
  44. If(D10 ≠ 0, Div[A11, B11], 0) → C11
  45. If(D10 ≠ 0, Mod[A11, B11], 0) → D11
  46. If(D11 ≠ 0, B11, 0) → A12
  47. If(D11 ≠ 0, D11, 0) → B12
  48. If(D11 ≠ 0, Div[A12, B12], 0) → C12
  49. If(D11 ≠ 0, Mod[A12, B12], 0) → D12
  50. If(D12 ≠ 0, B12, 0) → A13
  51. If(D12 ≠ 0, D12, 0) → B13
  52. If(D12 ≠ 0, Div[A13, B13], 0) → C13
  53. If(D12 ≠ 0, Mod[A13, B13], 0) → D13
  54. If(D13 ≠ 0, B13, 0) → A14
  55. If(D13 ≠ 0, D13, 0) → B14
  56. If(D13 ≠ 0, Div[A14, B14], 0) → C14
  57. If(D13 ≠ 0, Mod[A14, B14], 0) → D14
  58. If(D14 ≠ 0, B14, 0) → A15
  59. If(D14 ≠ 0, D14, 0) → B15
  60. If(D14 ≠ 0, Div[A15, B15], 0) → C15
  61. If(D14 ≠ 0, Mod[A15, B15], 0) → D15
  62. If(D15 ≠ 0, B15, 0) → A16
  63. If(D15 ≠ 0, D15, 0) → B16
  64. If(D15 ≠ 0, Div[A16, B16], 0) → C16
  65. If(D15 ≠ 0, Mod[A16, B16], 0) → D16
  66. If(D16 ≠ 0, B16, 0) → A17
  67. If(D16 ≠ 0, D16, 0) → B17
  68. If(D16 ≠ 0, Div[A17, B17], 0) → C17
  69. If(D16 ≠ 0, Mod[A17, B17], 0) → D17
  70. If(D17 ≠ 0, B17, 0) → A18
  71. If(D17 ≠ 0, D17, 0) → B18
  72. If(D17 ≠ 0, Div[A18, B18], 0) → C18
  73. If(D17 ≠ 0, Mod[A18, B18], 0) → D18
  74. If(D18 ≠ 0, B18, 0) → A19
  75. If(D18 ≠ 0, D18, 0) → B19
  76. If(D18 ≠ 0, Div[A19, B19], 0) → C19
  77. If(D18 ≠ 0, Mod[A19, B19], 0) → D19
  78. If(D19 ≠ 0, B19, 0) → A20
  79. If(D19 ≠ 0, D19, 0) → B20
  80. If(D19 ≠ 0, Div[A20, B20], 0) → C20
  81. Polygon(O, (a, 0), (a, b), (0, b)) → Rectangle, h1, v2, h2, v1
  82. If(D19 ≠ 0, Mod[A20, B20], 0) → D20
  83. KeepIf(x ≠ 0, Sequence[Object[Text["A" + (k)]], k, 1, 20]) → dividendes
  84. KeepIf(x ≠ 0, Sequence[Object[Text["B" + (k)]], k, 1, 20]) → diviseurs
  85. KeepIf(x ≠ 0, Sequence[Object[Text["C" + (k)]], k, 1, 20]) → quotients
  86. Polygon((0, 0), (Element[diviseurs, Length[diviseurs]], 0), (Element[diviseurs, Length[diviseurs]], Element[diviseurs, Length[diviseurs]]), (0, Element[diviseurs, Length[diviseurs]])) → Carre, c1, c2, c3, c4
  87. If(D20 ≠ 0, B20, 0) → A21
  88. If(D20 ≠ 0, D20, 0) → B21
  89. If(D20 ≠ 0, Div[A21, B21], 0) → C21
  90. If(D20 ≠ 0, Mod[A21, B21], 0) → D21
  91. If(D21 ≠ 0, B21, 0) → A22
  92. If(D21 ≠ 0, D21, 0) → B22
  93. If(D21 ≠ 0, Div[A22, B22], 0) → C22
  94. If(D21 ≠ 0, Mod[A22, B22], 0) → D22
  95. If(D22 ≠ 0, B22, 0) → A23
  96. If(D22 ≠ 0, D22, 0) → B23
  97. If(D22 ≠ 0, Div[A23, B23], 0) → C23
  98. If(D22 ≠ 0, Mod[A23, B23], 0) → D23
  99. If(D23 ≠ 0, B23, 0) → A24
  100. If(D23 ≠ 0, D23, 0) → B24
  101. If(D23 ≠ 0, Div[A24, B24], 0) → C24
  102. If(D23 ≠ 0, Mod[A24, B24], 0) → D24
  103. If(D24 ≠ 0, B24, 0) → A25
  104. If(D24 ≠ 0, D24, 0) → B25
  105. If(D24 ≠ 0, Div[A25, B25], 0) → C25
  106. If(D24 ≠ 0, Mod[A25, B25], 0) → D25
  107. If(D25 ≠ 0, B25, 0) → A26
  108. If(D25 ≠ 0, D25, 0) → B26
  109. If(D25 ≠ 0, Div[A26, B26], 0) → C26
  110. If(D25 ≠ 0, Mod[A26, B26], 0) → D26
  111. If(D26 ≠ 0, B26, 0) → A27
  112. If(D26 ≠ 0, D26, 0) → B27
  113. If(D26 ≠ 0, Div[A27, B27], 0) → C27
  114. If(D26 ≠ 0, Mod[A27, B27], 0) → D27
  115. If(D27 ≠ 0, B27, 0) → A28
  116. If(D27 ≠ 0, D27, 0) → B28
  117. If(D27 ≠ 0, Div[A28, B28], 0) → C28
  118. If(D27 ≠ 0, Mod[A28, B28], 0) → D28
  119. If(D28 ≠ 0, B28, 0) → A29
  120. If(D28 ≠ 0, D28, 0) → B29
  121. If(D28 ≠ 0, Div[A29, B29], 0) → C29
  122. If(D28 ≠ 0, Mod[A29, B29], 0) → D29
  123. If(D29 ≠ 0, B29, 0) → A30
  124. If(D29 ≠ 0, D29, 0) → B30
  125. If(D29 ≠ 0, Div[A30, B30], 0) → C30
  126. If(D29 ≠ 0, Mod[A30, B30], 0) → D30
  127. If(D30 ≠ 0, B30, 0) → A31
  128. If(D30 ≠ 0, D30, 0) → B31
  129. If(D30 ≠ 0, Div[A31, B31], 0) → C31
  130. If(D30 ≠ 0, Mod[A31, B31], 0) → D31
  131. If(D31 ≠ 0, B31, 0) → A32
  132. If(D31 ≠ 0, D31, 0) → B32
  133. If(D31 ≠ 0, Div[A32, B32], 0) → C32
  134. If(D31 ≠ 0, Mod[A32, B32], 0) → D32
  135. If(D32 ≠ 0, B32, 0) → A33
  136. If(D32 ≠ 0, D32, 0) → B33
  137. If(D32 ≠ 0, Div[A33, B33], 0) → C33
  138. If(D32 ≠ 0, Mod[A33, B33], 0) → D33
  139. If(D33 ≠ 0, B33, 0) → A34
  140. If(D33 ≠ 0, D33, 0) → B34
  141. If(D33 ≠ 0, Div[A34, B34], 0) → C34
  142. If(D33 ≠ 0, Mod[A34, B34], 0) → D34
  143. If(D34 ≠ 0, B34, 0) → A35
  144. If(D34 ≠ 0, D34, 0) → B35
  145. If(D34 ≠ 0, Div[A35, B35], 0) → C35
  146. If(D34 ≠ 0, Mod[A35, B35], 0) → D35
  147. If(D35 ≠ 0, B35, 0) → A36
  148. If(D35 ≠ 0, D35, 0) → B36
  149. If(D35 ≠ 0, Div[A36, B36], 0) → C36
  150. If(D35 ≠ 0, Mod[A36, B36], 0) → D36
  151. If(D36 ≠ 0, B36, 0) → A37
  152. If(D36 ≠ 0, D36, 0) → B37
  153. If(D36 ≠ 0, Div[A37, B37], 0) → C37
  154. If(D36 ≠ 0, Mod[A37, B37], 0) → D37
  155. If(D37 ≠ 0, B37, 0) → A38
  156. If(D37 ≠ 0, D37, 0) → B38
  157. If(D37 ≠ 0, Div[A38, B38], 0) → C38
  158. If(D37 ≠ 0, Mod[A38, B38], 0) → D38
  159. If(D38 ≠ 0, B38, 0) → A39
  160. If(D38 ≠ 0, D38, 0) → B39
  161. If(D38 ≠ 0, Div[A39, B39], 0) → C39
  162. If(D38 ≠ 0, Mod[A39, B39], 0) → D39
  163. If(D39 ≠ 0, B39, 0) → A40
  164. If(D39 ≠ 0, D39, 0) → B40
  165. If(D39 ≠ 0, Div[A40, B40], 0) → C40
  166. If(D39 ≠ 0, Mod[A40, B40], 0) → D40
  167. If(D40 ≠ 0, B40, 0) → A41
  168. If(D40 ≠ 0, D40, 0) → B41
  169. If(D40 ≠ 0, Div[A41, B41], 0) → C41
  170. If(D40 ≠ 0, Mod[A41, B41], 0) → D41
  171. If(D41 ≠ 0, B41, 0) → A42
  172. If(D41 ≠ 0, D41, 0) → B42
  173. If(D41 ≠ 0, Div[A42, B42], 0) → C42
  174. If(D41 ≠ 0, Mod[A42, B42], 0) → D42
  175. If(D42 ≠ 0, B42, 0) → A43
  176. If(D42 ≠ 0, D42, 0) → B43
  177. If(D42 ≠ 0, Div[A43, B43], 0) → C43
  178. If(D42 ≠ 0, Mod[A43, B43], 0) → D43
  179. If(D43 ≠ 0, B43, 0) → A44
  180. If(D43 ≠ 0, D43, 0) → B44
  181. If(D43 ≠ 0, Div[A44, B44], 0) → C44
  182. If(D43 ≠ 0, Mod[A44, B44], 0) → D44
  183. If(D44 ≠ 0, B44, 0) → A45
  184. If(D44 ≠ 0, D44, 0) → B45
  185. If(D44 ≠ 0, Div[A45, B45], 0) → C45
  186. If(D44 ≠ 0, Mod[A45, B45], 0) → D45
  187. If(D45 ≠ 0, B45, 0) → A46
  188. If(D45 ≠ 0, D45, 0) → B46
  189. If(D45 ≠ 0, Div[A46, B46], 0) → C46
  190. If(D45 ≠ 0, Mod[A46, B46], 0) → D46
  191. If(D46 ≠ 0, B46, 0) → A47
  192. If(D46 ≠ 0, D46, 0) → B47
  193. If(D46 ≠ 0, Div[A47, B47], 0) → C47
  194. If(D46 ≠ 0, Mod[A47, B47], 0) → D47
  195. If(D47 ≠ 0, B47, 0) → A48
  196. If(D47 ≠ 0, D47, 0) → B48
  197. If(D47 ≠ 0, Div[A48, B48], 0) → C48
  198. If(D47 ≠ 0, Mod[A48, B48], 0) → D48
  199. If(D48 ≠ 0, B48, 0) → A49
  200. If(D48 ≠ 0, D48, 0) → B49
  201. If(D48 ≠ 0, Div[A49, B49], 0) → C49
  202. If(D48 ≠ 0, Mod[A49, B49], 0) → D49
  203. If(D49 ≠ 0, B49, 0) → A50
  204. If(D49 ≠ 0, D49, 0) → B50
  205. If(D49 ≠ 0, Div[A50, B50], 0) → C50
  206. If(D49 ≠ 0, Mod[A50, B50], 0) → D50
  207. If(a ≥ b, 1, 0) → f
  208. Sequence(Sequence[Segment[(Element[dividendes, j] - i * Element[diviseurs, j], 0), (Element[dividendes, j] - i * Element[diviseurs, j], Element[diviseurs, j])], i, 1, Element[quotients, j]], j, 2 - f, Length[dividendes], 2) → SegmentsV
  209. Sequence(Sequence[Segment[(0, Element[dividendes, j] - i * Element[diviseurs, j]), (Element[diviseurs, j], Element[dividendes, j] - i * Element[diviseurs, j])], i, 1, Element[quotients, j]], j, 1 + f, Length[dividendes], 2) → SegmentsH

AI Drawing Prompt Reference

Draw a rectangle whose length and width are the two input positive integers. The rectangle is progressively subdivided into squares, each square's side length corresponding to the current remainder. The process continues until a final square remains, whose side length is the GCD of the original numbers. The drawing should clearly show the subdivision steps and the final square, illustrating the geometric meaning of the Euclidean algorithm.
The prompt above was compiled from the original drawing commands and is for reference only.