In: Electrical Engineering
Code for the function is given in the following image-
The results after testing the function-
You can copy following code in Matlab and test it.
function [result] = moreFactors(a,b,fact)
if(rem(a,fact)==0)
m=0;
else
m=1;
end
if(rem(b,fact)==0)
n=0;
else
n=1;
end
if(m==0&&n~=0)
result=a;
elseif(m~=0&&n==0)
result=b;
elseif(m~=0&&n~=0)
result=max([a,b]);
elseif(m==0&&n==0)
fact=fact*fact;
result=moreFactors(a,b,fact); %Recursion
end
end