Least common multiple/ru
English · Français · Suomi · Русский
Наименьшим общим кратным (НОК) двух целых чисел $a$ и $b$ является наименьшее положительное целое число, которое делится на оба числа $a$ и $b$.
Например: для чисел 12 и 9 наименьшим общим кратным будет число 36.
Функция leastCommonMultiple
function leastCommonMultiple(a, b: Int64): Int64;
begin
result := b * (a div greatestCommonDivisor(a, b));
end;Note: Функция greatestCommonDivisor должна быть объявлена перед функцией leastCommonMultiple.
См. также
- Наибольший общий делитель
- mpz_lcm в GMP (библиотека высокой точности GNU)
From the Free Pascal wiki, page "Least common multiple/ru", as it stood on 2018-02-13 after a change by Useroflazarus, 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.
Talk about this page
Nobody has opened a bench for this page yet. Sign in to open one.
