Var a,b,k:integer;
begin
writeln('a, b:');
readln(a,b);
k:=0;
while a<>b do
begin
k:=k+1;
if a>b
then begin writeln(k,': ',b,'*',b); a:=a-b; end
else begin writeln(k,': ',a,'*',a); b:=b-a; end;
end;
k:=k+1;
writeln(k,': ',a,'*',a);
writeln('k = ',k);
end.
Пример:
a, b:
3 8
1: 3*3
2: 3*3
3: 2*2
4: 1*1
5: 1*1
k = 5