bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-gnulib] lcm


From: Davide Angelocola
Subject: [Bug-gnulib] lcm
Date: Tue, 2 Nov 2004 21:56:37 +0100

Hi,
I'm playing with gnulib and I've discovered that there is a gcd() function but not an lcm() one. The following relation:

                  |a * b|
 lcm(a,b) = ---------
                 gcd(a,b)

that translated into C code should look like this:

unsigned long
lcm(unsigned long a, unsigned long b)
{
        return labs(a * b) / gcd(a, b);
}

this should give a somewhat portable and even fast lcm() implementation.

Best Regards,
  -- Davide Angelocola





reply via email to

[Prev in Thread] Current Thread [Next in Thread]