MATLAB: Syntax error,the goal is to calculate the smallest common divisor with the entered numbers. but I can not do . it constantly gives syntax error. given by fprintf

errorhelpMATLAB

a=input ('1.tamsayi: '); b=input ('2.tamsayi: ');
for i=1:a*b
if((mod(i,a)==0) && (mod(i,b)==0)
fprintf (' \nOkek(%d,%d)=%d\n',a,b,i);
break
c=max([a b]);
for i =c:-1:1
if ((mod(a,i)==0 && (mod(b,i)==0)))
fprintf('OBEB(&d,%d)=%d\n',a,b,i);
break
endif
endfor
endfor

Best Answer

In the first if condition you forgot to close the bracket, so the error.
clc; clear all ;
a=input ("1.tamsayi: "); b=input ("2.tamsayi: ");
for i=1:a*b
if((mod(i,a)==0) && (mod(i,b)==0))
fprintf("\nOkek(%d,%d)=%d\n",a,b,i);
break
end
c=max([a b]);
for i =c:-1:1
if ((mod(a,i)==0 && (mod(b,i)==0)))
fprintf('OBEB(&d,%d)=%d\n',a,b,i);
break
end
end
end