/src/numtheory/fp_lcm.c
C | 20 lines | 15 code | 2 blank | 3 comment | 3 complexity | 467f4f0348ac56b5fd4b88e9b865c58f MD5 | raw file
Possible License(s): Unlicense
1/* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */ 2/* SPDX-License-Identifier: Unlicense */ 3#include <tfm_private.h> 4 5/* c = [a, b] */ 6void fp_lcm(fp_int *a, fp_int *b, fp_int *c) 7{ 8 fp_int t1, t2; 9 10 fp_init(&t1); 11 fp_init(&t2); 12 fp_gcd(a, b, &t1); 13 if (fp_cmp_mag(a, b) == FP_GT) { 14 fp_div(a, &t1, &t2, NULL); 15 fp_mul(b, &t2, c); 16 } else { 17 fp_div(b, &t1, &t2, NULL); 18 fp_mul(a, &t2, c); 19 } 20}