how is calculated gcd of 4 number? [closed]
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
开发者_C百科 Improve this questiondoes gcd(gcd(a,b),gcd(c,d))
equal gcd(a,b,c,d)
?or how can i calculate gcd of 4 number?
yes that is correct. If you are finding the gcd of (a,b,c,d) then any split should work. So gcd(a,b,c,d) = gcd(gcd (a,b) , gcd(c,d))
Yes. GCD(a,b,c,d) = GCD(a, GCD(b, GCD(c, d))) (or any other order, its associative and commutative.) Oh, and just in case you didn't know, you can use the Euclidean algorithm to compute GCD very quickly.
精彩评论