Please use MATLAB and explain how to input code. I can't use
anything too complex, the things i've learned are matrices,
vectors, functions and anonymous functions and plotting, if
statements, for loops and while loops! Thank you so much!
:) DO NOT USE BREAK
(Euclidean Algorithm) As mentioned in class, the Euclidean algorithm is useful for finding the GCD of two numbers A and B by producing the sequence Rn by
R =
mod (A,B), Rz
mod (B, R1); Rn
mod (Rn-2, Rn-1)
for n 2 2. The last non-zero number in the sequence is the GCD of A and B.
euclid_gcd Function: Input variables: scalar representing A a scalar representing B (which you may assume is not equal to A) Output variables: scalar representing the GCD of A and B a vector of all iterates produced (this vector should include R1 and Rz its first entries as well as the final zero entry)
possible sample case is:
>> [GCD _ R] GCD
euclid_gcd(32 , 40)
32
>> [GCD , R] GCD
euclid_gcd(100 , 65)
35
30