Least common multiple

From Lazarus wiki
Revision as of 08:23, 7 March 2015 by Djzepi (talk | contribs) (Created page with " 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 LeastCo...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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;
Light bulb  Note: Function GreatestCommonDivisor must be defined before this function


See also