Euclidean Algorithm
Here are two Matlab scripts for looking at the Euclidean algorithm:
- Euclid1.m expects to find two integers,
a and b, and it returns the gcd(a,b) (now called "a", by the end of
the algorithm) and "count", the number of steps needed to find it.
- Euclid2.m. This one generates M
random pairs of integers (a,b) between 1 and N inclusive, and
reports statistics on the distribution of gcd's and numbers of
steps required.