Difference between revisions of "Least common multiple"
From Lazarus wiki
Jump to navigationJump to search (add Category:Mathematics) |
|||
Line 5: | Line 5: | ||
For example: for 12 and 9 then least common multiple is 36. | For example: for 12 and 9 then least common multiple is 36. | ||
− | == <syntaxhighlight lang="pascal" | + | == <syntaxhighlight lang="pascal" inline>function leastCommonMultiple</syntaxhighlight> == |
<syntaxhighlight lang="pascal"> | <syntaxhighlight lang="pascal"> | ||
Line 14: | Line 14: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | {{Note|[[Greatest common divisor#function greatestCommonDivisor|<syntaxhighlight lang="pascal" | + | {{Note|[[Greatest common divisor#function greatestCommonDivisor|<syntaxhighlight lang="pascal" inline>function greatestCommonDivisor</syntaxhighlight>]] must be at least declared before this function.}} |
== see also == | == see also == | ||
* [[Greatest common divisor|greatest common divisor]] | * [[Greatest common divisor|greatest common divisor]] | ||
− | * <syntaxhighlight lang="pascal" | + | * <syntaxhighlight lang="pascal" inline>mpz_lcm</syntaxhighlight> in [[gmp|GMP]] (GNU multiple precision) |
[[Category:Mathematics]] | [[Category:Mathematics]] |
Latest revision as of 17:13, 6 August 2022
│
English (en) │
suomi (fi) │
français (fr) │
русский (ru) │
The least common multiple of two integers [math]\displaystyle{ a }[/math] and [math]\displaystyle{ b }[/math] is the smallest positive integer that is divisible by both [math]\displaystyle{ a }[/math] and [math]\displaystyle{ b }[/math].
For example: for 12 and 9 then least common multiple is 36.
function leastCommonMultiple
function leastCommonMultiple(a, b: Int64): Int64;
begin
result := b * (a div greatestCommonDivisor(a, b));
end;
Note:
function greatestCommonDivisor
must be at least declared before this function.see also
- greatest common divisor
mpz_lcm
in GMP (GNU multiple precision)