good morning

this is the first question for me in this great forum an i hope to help me.

e.g.let a = 175 ,b = 40

175=40(4)+15

40 = 15(2)+10

15=10(1)+5

10=5(2)+0

so GCD(175,40)=5

j q sj tj

-1 1 0

0 0 1

1 4 1 -4

2 2 -2 9

3 1 3 -13

so x=3 , y=-13

so 175*3+40*(-13)=5

note sj+1 = sn-1 - sn * qn+1

tn+1 = tn-1 - tn * qn+1

now my question how can i write this method in matlab langauge?

I Try to write it but i faild : i wrote this :

a= input('a=')

b= input('b=')

r(0)=a;

r(1)=b;

for i =0:10

q(i) = floor(r(i-2)/r(i-1));

r(i) = (r(i-2)/r(i-1)- q(i))*r(i-1);

end

stop r(i) = 0

h= i

s(-1)=1;

s(0)=0;

t(-1)=0;

t(0)=1;

for j = 1 : h-1

s(j)=s(j-2)-s(j-1)*q(i);

t(j)=t(j-2)-t(j-1)*q(j);

end

x=s(h-1)

y= t(h-1)

gcd = a*x+b*y

please i ask u to help and thanks alot for all