Least common multiple: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: Least common multiple
| Old | New | Line | |
|---|---|---|---|
| 1 | + | The least common multiple of two integers $`a`$ and $`b`$ is the smallest positive integer that is divisible by both $`a`$ and $`b`$. | |
| 2 | + | ||
| 3 | + | For example: for 12 and 9 then least common multiple is 36. | |
| 4 | + | ||
| 5 | + | ## `function leastCommonMultiple` | |
| 6 | + | ||
| 7 | + | ``` pascal | |
| 8 | + | function leastCommonMultiple(a, b: Int64): Int64; | |
| 9 | + | begin | |
| 10 | + | result := b * (a div greatestCommonDivisor(a, b)); | |
| 11 | + | end; | |
| 12 | + | ``` | |
| 13 | + | ||
| 14 | + | > **Note:** [[Greatest common divisor|function greatestCommonDivisor]] must be at least declared before this function. | |
| 15 | + | ||
| 16 | + | ## see also | |
| 17 | + | ||
| 18 | + | - [[Greatest common divisor|greatest common divisor]] | |
| 19 | + | - `mpz_lcm` in [[gmp|GMP]] (GNU multiple precision) | |
| 20 | + | ||
| 21 | + | --- | |
| 22 | + | *From the Free Pascal wiki, page "Least common multiple", as it stood on 2022-08-06 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* | |
| 23 | + | Category: Mathematics |
