GCF (Greatest Common Factor/Divisor)

Hi Everyone,

I searched this community for information on the Loop triplet of operators and could not find information sufficient to help me with my attempt at using the operators in context of finding the greatest common factor/divisor of two numbers using the Euclidean Algorithm.

My idea was to use them alongside small bits of EKL scripts hosted by Script nodes with the webapp xGenerative Design as this is what students have access to.

 

Here is my working EKL script for the numbers 15 & 18, where a = 15 and b = 18:

 

Let a, b, temp (Integer)
a = aLC //Input
b = bLC //Input
if a < 0
{
 a = -a
}
if b < 0
{
 b = -b
}
for b while b <> 0
{
temp = a - floor(a / b) * b
a = b
b = temp
}
oGC = a //Output

 

To help beginning math high school students with stepping through the Euclidean Algorithm, I was hoping to use the Loop nodes in place of the /* for b while b <> 0 */ with the possible help of some sister conditional and/or test nodes.

 

I was thinking of using the Euclidean algorithm as a process of breaking down geometry into smaller, repeatable shapes—like generating nested constructions until students find a fundamental building block. Here’s how I was thinking of the visual:

  1. Imagine students have two line segments: one represents length a and the other represents length b.

  2. Arrange these two line segments to form the sides of a rectangle—one side is length a, and the adjoining side is length b. Now students have a rectangle whose dimensions are based on the two lengths.

  3. From this rectangle, students cut out the largest square possible along one side. For instance, if a students rectangle is a units wide and b units tall, and a > b, students can slice off a b x b square. This leaves you with a smaller rectangle (or possibly a line segment) because students used up one dimension completely.

  4. Now students have a smaller rectangle defined by the leftover portion. If the leftover piece is still not a perfect square, repeat the process:

    • Students take the shorter side of the leftover rectangle and cut squares from the longer side.
    • Students keep doing this until one dimension lines up perfectly and you’re left with a square that can tile the entire construction.
    •  
  5. Eventually, the process hits a point where students can carve out a square that divides both original lengths exactly, leaving no remainder. The side length of that final perfect square corresponds to the greatest common factor of the original lengths a and b.

Generative Geometry Interpretation:

  • Iteration as Geometry: Each step in the Euclidean algorithm corresponds to creating or removing geometric primitives (squares) from a larger figure.
  • Parametric Process: Just as students repeatedly compute division remainders, students repeatedly generate new geometry (squares and leftover rectangles) until no smaller leftover shape remains.
  • Final Shape: The last stable form, a perfect square, can be viewed as the “genetic code” of both starting lengths. It’s the largest geometric unit that can build both line segments without leftover fragments.

 

I think I'm close but need other minds on it as I don't know how to include the Loop operators in a way that students can use xGenerative Design to find GCFs/GCDs.  It would be so cool if xGD could be their go-to app for visually/generatively understanding what is happening in the GCF/GCD process.  For students, it needs to be a concrete, short visual script.

 

Thank you for your time

 

Euclidean algorithm Loop Conditional Integrated Math 1 Math