gcd static method

int gcd(
  1. int a,
  2. int b
)

Get greatest common divisor

a - First number b - Second number Returns GCD of the two numbers

Implementation

static int gcd(int a, int b) {
  while (b != 0) {
    final temp = b;
    b = a % b;
    a = temp;
  }
  return a;
}