Euclidean greatest common divisor for more than two numbers

前端 未结 6 1362
谎友^
谎友^ 2020-12-16 14:48

Can someone give an example for finding greatest common divisor algorithm for more than two numbers?

I believe programming language doesn\'t matter.

6条回答
  •  星月不相逢
    2020-12-16 15:44

    The GCD of 3 numbers can be computed as gcd(a, b, c) = gcd(gcd(a, b), c). You can apply the Euclidean algorithm, the extended Euclidian or the binary GCD algorithm iteratively and get your answer. I'm not aware of any other (smarter?) ways to find a GCD, unfortunately.

提交回复
热议问题