Finding Greatest Common Divisor

Is there a function or algorithm in stl in c++ which can help me find out the gcd of a vector ?
Last edited on
Yes. Assuming v is your vector and gcd a binary function, you can do:

std::accumulate(v.begin(), v.end(), v[0], gcd)

http://www.cplusplus.com/reference/numeric/accumulate/
Topic archived. No new replies allowed.