Răspuns:
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("numere.in");
int n, num, i, d;
int cmmdc(int a, int b)
{
int r;
while (b!=0)
{
r=a%b;
a=b;
b=r;
}
return a;
}
int main()
{
f >> n >> num;
d=num;
for (i=2; i<=n; ++i)
{
f >> num;
d=cmmdc(d,num);
}
cout << d;
}
Explicație: