Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int NWD (int x, int y)
- {
- int a;
- while (y)
- {
- a=x%y;
- x=y;
- y=a;
- }
- return x;
- }
- int main()
- {
- int j, tmpNWD=0;
- cin >> j;
- vector <int> vec (j);
- for (int i=0; i<j; i++)
- cin >>vec [i];
- for (int i =0; i<j; i++)
- tmpNWD = NWD (vec[i], tmpNWD);
- cout <<tmpNWD;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement