HOW IT WORKS
Euclidean algorithm for GCF & GCD
The greatest common factor (GCF)—also called the greatest common divisor (GCD)—is the largest positive integer that divides every integer in a set without leaving a remainder.
Euclidean remainder step
Repeatedly replace the larger integer with the remainder of dividing it by the smaller integer until the remainder reaches zero:
GCD(a, b) = GCD(b, a mod b), GCD(a, 0) = |a|Folding across 3+ integers
For multiple integers, the GCD operation is associative, so folding pairwise produces the exact GCF of the entire list:
GCF(a, b, c) = GCF(GCF(a, b), c)Exact BigInt arithmetic
All remainders are evaluated in BigInt integer arithmetic so large integers never lose precision.
GCF(24, 36, 60) = 12