.\" Copyright 2026 Andrew V.Kosteltsev (kx@radix-linux.su) .\" .\" .TH ilcm 3 "September 14, 2026" "libmpu" "LibMPU Programmer's Manual" .SH NAME \fBilcm\fP \- least common multiple of unsigned integers .SH SYNOPSIS .nf .B #include .PP .BI "void ilcm( mpu_int *" c ", mpu_int *" a ", mpu_int *" b ", int " nb " );" .fi .SH DESCRIPTION The \fBilcm()\fP function computes the least common multiple (LCM) of the unsigned integers located at addresses \fBa\fP and \fBb\fP and places the result at address \fBc\fP. The calculation is performed as .sp .nf lcm(a, b) = (a / gcd(a, b)) * b .fi .sp which avoids forming \fBa * b\fP before division by the GCD. The memory contents at addresses \fBa\fP and \fBb\fP are not changed. The \fBnb\fP parameter determines the size of all operands, in bytes. .PP The following zero-operand semantics are used: .nf .sp lcm(0, b) = 0 lcm(a, 0) = 0 lcm(0, 0) = 0 .fi .PP If the mathematical LCM does not fit in \fBnb\fP bytes, the low-order \fBnb\fP bytes are stored at \fBc\fP and the \fBO\fP (Overflow) flag is set. The \fBZ\fP flag indicates a zero result. The \fBP\fP and \fBS\fP flags are set according to the stored result where applicable; \fBP\fP is defined only for one- and two-byte integer operations. .sp .SH EXAMPLES .nf .sp #include #include int main( void ) { mpu_int1024_t c, a, b; int nb = NB_I1024; __mpu_char8_t s[4096]; __mpu_init(); iatoui( a, "12", nb ); iatoui( b, "18", nb ); ilcm( c, a, b, nb ); iuitoa( s, c, RADIX_DEC, LOWERCASE, nb ); printf( "c = %s;\\n", s ); /* c = 36; */ __mpu_free_context(); return( 0 ); } .fi .sp .SH SEE ALSO .BR iadd(3), .BR isub(3), .BR iadc(3), .BR isbb(3), .BR ineg(3), .BR inot(3), .BR iand(3), .BR itest(3), .BR icmp(3), .BR ior(3), .BR ixor(3), .BR iinc(3), .BR idec(3), .BR ixchg(3), .BR icpy(3), .BR icvt(3), .BR imul(3), .BR ismul(3), .BR idiv(3), .BR isdiv(3), .BR iatoi(3), .BR iatoui(3), .BR iitoa(3), .BR iuitoa(3), .BR _int_digs(3), .BR ibits_len(3), .BR igcd(3), .BR imod(3), .BR imul_mod(3), .BR ipow_mod(3), .BR ipowm1_mod(3), .BR shifts(3), .BR shifts\-n(3), .BR circular\-shifts(3), .BR circular\-shifts\-n(3), .BR integer\-flags(3), .BR real\-flags(3), .BR libmpu(7).