I am trying to program the Extended Euclidean Algorithm. Earlier I made some progress past simply generating garbage data. I am supposed to yield two constants s & t that would help compute the constants needed in the Algorithm. However, I cannot compute the right numbers that I need. Here is my function below:
ExtendoEuclid[x_, y_] :=
Module[{a, b, s = {}, t = {}, q, r, i, sNew, tNew},
{a, b, i} = {x, y, 2};
If[b == 0, Return[0],
s = {1, 0};
t = {0, 1};
While[r != 0,
r = Mod[a, b];
q = (a - r)/b;
Print[q];
Print[r];
sNew = s[i] - s[i - 1]*q;
tNew = t[i] - t[i - 1]*q;
AppendTo[s, sNew];
AppendTo[t, tNew];
a = b;
b = r;
i++;
];
];
Print[Last[s]];
Print[Last[t]]
]
ExtendoEuclid[1873, 19]
s
andt
? $\endgroup$