tags:

views:

59

answers:

2

does gcd(gcd(a,b),gcd(c,d)) equal gcd(a,b,c,d)?or how can i calculate gcd of 4 number?

+4  A: 

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))

Sagar V
+1 for jinx! :)
JoshD
+4  A: 

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.

JoshD
+1. Returning the goodwill :)
Sagar V