Greatest common divisor

Built-in

var arr = [100, 1_000, 10_000, 20]
say Math.gcd(arr...)

Recursive Euclid algorithm

func gcd(a, b) {
    b==0 ? a.abs : gcd(b, a % b)
}

Last updated