gcd method

int gcd(
  1. int other
)

Returns the greatest common divisor of this and other.

12.gcd(8) // 4

Implementation

int gcd(int other) {
  var a = toInt().abs();
  var b = other.abs();
  while (b != 0) {
    final t = b;
    b = a % b;
    a = t;
  }
  return a;
}