Least Common Multiple添加链接描述
#include <stdio.h>
int gcd(int a,int b);
int main()
{
int n;
scanf("%d",&n);
int i;
int n1,j,x,y;
for (i=1;i<=n;i++){
scanf("%d %d",&n1,&x);
for (j=1;j<n1;j++){
scanf("%d",&y);
x=gcd(x,y);
}
printf("%d\n",x);
}
return 0;
}
int gcd(int a,int b)
{
int c;
c=a;
while (a%b!=0){
a=a+c;
}
return a;
}