type
Utilities = class
public
class method GCD(left, right: Integer): Integer;
end;
implementation
{ Utilities }
class method Utilities.GCD(left, right: Integer): Integer;
begin
// repeat everything from begin to end as long as right is not 0.
while right <> 0 do begin
// defines a new variable that returns left modulus right.
var rem := left mod right;
// sets left to right.
left := right;
// sets right to the earlier calculated remainder.
right := rem;
end;
// return the left value.
exit left;
end;
var x : Integer;
begin
x:= Utilities.GCD(23500, 14100);
WriteLn(x);
end;
//solution: 4700
|