private static long FastExtEuclid(
long a,
long b,
long[] uOut)
{
long u1 = 1;
long u3 = a;
long v1 = 0;
long v3 = b;
while (v3 > 0)
{
long q, tn;
q = u3 / v3;
tn = u1 - (v1 * q);
u1 = v1;
v1 = tn;
tn = u3 - (v3 * q);
u3 = v3;
v3 = tn;
}
uOut[0] = u1;
uOut[1] = (u3 - (u1 * a)) / b;
return u3;
}