Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include <cmath>
- #include <vector>
- int gcd(int a, int b) {
- while (a != 0 && b != 0)
- if (a > b) a %= b;
- else b %= a;
- return a + b;
- }
- int main()
- {
- int n = 0;
- int a = 0, b = 0;
- scanf_s("%d%d", &n, &b);
- for (int i = 1; i < n; i++)
- {
- scanf_s("%d", &a);
- b = gcd(a, b);
- }
- printf("%d", b);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement