Advertisement
Guest User

Untitled

a guest
Feb 26th, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int NWD (int x, int y)
  6. {
  7. int a;
  8. while (y)
  9. {
  10. a=x%y;
  11. x=y;
  12. y=a;
  13. }
  14. return x;
  15. }
  16.  
  17. int main()
  18. {
  19. int j, tmpNWD=0;
  20. cin >> j;
  21. vector <int> vec (j);
  22. for (int i=0; i<j; i++)
  23. cin >>vec [i];
  24. for (int i =0; i<j; i++)
  25. tmpNWD = NWD (vec[i], tmpNWD);
  26. cout <<tmpNWD;
  27.  
  28. return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement