mirror of
https://hub.njuu.cf/TheAlgorithms/C-Plus-Plus.git
synced 2023-10-11 13:05:55 +08:00
21 lines
275 B
C++
21 lines
275 B
C++
#include <iostream>
|
|
using namepsace std;
|
|
int main()
|
|
{
|
|
cin >> n;
|
|
int a[n];
|
|
int i,j,gcd;
|
|
for(i=0;i<n;i++)
|
|
cin >> a[i];
|
|
j=1;
|
|
gcd=a[0];
|
|
while(j<n)
|
|
{
|
|
if(a[j]%gcd==0)
|
|
j++;
|
|
else
|
|
gcd=a[j]%gcd;
|
|
}
|
|
cout << "GCD of entered n numbers:" << gcd;
|
|
}
|