Least common multiple
From Lazarus wiki
Jump to navigationJump to search
The least common multiple is the smallest positive integer that is divisible by both a and b.
If numbers are 12 and 9 then least common multiple is 36.
Function LeastCommonMultiple
function LeastCommonMultiple( a, b: Int64 ): Int64;
var
temp : Int64;
begin
temp := a div ( GreatestCommonDivisor( a, b ) );
result := temp * b;
end;
Note: Function GreatestCommonDivisor must be defined before this function