void exgcd(int a,int b,int &x,int &y)
{ if (b) {exgcd(b,a%b,y,x);y-=x*(a/b);} else x=1,y=0; } int main() { int x,y; for(int i=1;i<=1000;i++) for(int j=i;j<=1000;j++) { exgcd(i,j,x,y); assert(max(abs(x),abs(y))<=max(i,j)); } }
this code ends without exception,that is to say,the root x,y equals or smaller than max(i,j) in [1..1000,1..1000].
I just wonder if it will hold for any i,j?
can anyone prove or disprove it?