#include <iostream>
using namespace std;
int gcd(int a,int b){
if(!a)
return b;
return gcd(b%a,a);
}
int main(){
int n;
cin>>n;
while(n){
int ans=0;
int x;
cin>>x;
while(x){
ans=gcd(ans,x-n);
cin>>x;
}
cout<<(ans>0?ans:-ans)<<endl;
cin>>n;
}
}
using namespace std;
int gcd(int a,int b){
if(!a)
return b;
return gcd(b%a,a);
}
int main(){
int n;
cin>>n;
while(n){
int ans=0;
int x;
cin>>x;
while(x){
ans=gcd(ans,x-n);
cin>>x;
}
cout<<(ans>0?ans:-ans)<<endl;
cin>>n;
}
}
Comments
Post a Comment