Static method example



The euclidean algorithm for computing the greatest common divisor, can be used to find a number both left and right can be divided by.

The challenge is solving the follow problem:
Two plots of land with areas of 23,500 m² (square meters) and 14,100m² (square meters) are divided into lots, as large as possible, all in the same area. The total number of lots obtained, is:
Please implement this using static method. Remember a static method does not need an instance to be called
Smart pascal source code
unit E; interface uses SmartCL.System; 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; end. { filename: umain.pas } var x : Integer; begin x:= Utilities.GCD(23500, 14100); WriteLn(x); // //solution: 4700 end; end;