I am seeking for the easiest solution to get the greatest common divisor of multiple values. Something like:
x=gcd_array(30,40,35) % Should return 5
x=gcd_array(30,40) % Should return 10
How would you solve this?
Many thanks!
gcd(a,b,c) = gcd(a,gcd(b,c))
Which means you can use recursion.
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.73.3&rep=rep1&type=pdf&ei=90jgT9KPAtLS4QSNlOGdDQ&usg=AFQjCNGH_GewFofxWPfX2BDN6T5NF9PxAA
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With