gcd

tailrec fun gcd(a: Int, b: Int): Int
tailrec fun gcd(a: Long, b: Long): Long

Computes Greatest Common Divisor of a and b.

It's computed by Euclidean algorithm. Hence, its time complexity is \(O(\log(a+b))\) (see Wolfram MathWorld).


fun gcd(vararg values: Int): Int
fun gcd(values: Iterable<Int>): Int
fun gcd(vararg values: Long): Long
fun gcd(values: Iterable<Long>): Long

Computes Greatest Common Divisor of the values.