Bezout's equation for Gaussian integers and Z[√2]
The Euclidean algorithm for Gaussian integers,
properly done, starts with Gaussian integers a
and b and calculates Gaussian integers s and t such that
sa + tb divides both a and b. It follows
that sa + tb is a greatest common divisor of
a and b.
This program accepts Gaussian integers in the form 3 + 2i, or elements
of Z[√2] in the form 3 + 2r,
where r stands for √2
(but not simultaneously).