Logo

Programming-Idioms

History of Idiom 75 > diff from v25 to v26

Edit summary for version 26 by derSteFfi:
New C implementation by user [derSteFfi]

Version 25

2019-09-26, 20:18:50

Version 26

2019-09-27, 10:45:45

Idiom #75 Compute LCM

Compute the least common multiple x of big integers a and b. Use an integer type able to handle huge numbers.

Idiom #75 Compute LCM

Compute the least common multiple x of big integers a and b. Use an integer type able to handle huge numbers.

Imports
#include <gmp.h>
Code
mpz_t _a, _b, _x;
mpz_init_set_str(_a, "123456789", 10);
mpz_init_set_str(_b, "987654321", 10);
mpz_init(_x);

mpz_lcm(_x, _a, _b);
gmp_printf("%Zd\n", _x);
Doc URL
https://gmplib.org/manual/Number-Theoretic-Functions.html#Number-Theoretic-Functions