fork(6) download
  1. #include <iostream>
  2. using namespace std;
  3. int gcd(int a, int b) {
  4. return (a == 0) ? b: gcd(b % a, a);
  5. }
  6.  
  7. int main() {
  8. int n, m = 0;
  9. cin >> n;
  10. for (int i = 0; i < n; i++) {
  11. int a;
  12. cin >> a;
  13. m = gcd(m, a);
  14. }
  15. cout << m;
  16. return 0;
  17. }
Success #stdin #stdout 0s 15232KB
stdin
4
132 36 66 18
stdout
6