Discrete math 1) Using MatLab (any language is fine just say what language is used). function d=lemma_gcd(a,b) %This program...

90.2K

Verified Solution

Question

Advance Math

Discrete math

1) Using MatLab (any language is fine just saywhat language is used).

function d=lemma_gcd(a,b)
%This program will return the greatest common divisor for inputvariables a
%and b where a and b are integers such that they are not both 0. Ituses
%Lemma 4.8.3 on page 225.

%Note: gcd(a,b)=gcd(-a,b)=gcd(a,-b)=gcd(-a,-b), so
a=abs(a);
b=abs(b);

%This following section sets up the arrays we will use to storethe
%changing values of our variables as a sequence. "c" will be thecount
%variabe, stored in "C", "a" and "b" will also bechanging andstored in "A"
%and "B" arrays through the iterations of the loops.

c=0;
C(1)=c; %Stores c=0 in the array, C
%Next find the initial a and b to kick the program into gear


if a==0 & b==0
fprintf('You cannot input these variables')
d=inf;
else
if floor(a)~=a
fprintf('You cannot input these variables')
d=inf;
if floor(b)~=b
fprintf('You cannot input these variables')
d=inf;
  
  
  
  
  
  
  
  
end
end
end

Answer & Explanation Solved by verified expert
3.7 Ratings (554 Votes)
MATLAB CODEfunction dlemmagcdabThis program will return the greatest common divisor for inputvariables aand b where a and b are integers such that they are not both 0It usesLemma 483 on page    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students