lcm.c 265 B

12345678910111213141516
  1. #include <linux/kernel.h>
  2. #include <linux/gcd.h>
  3. #include <linux/module.h>
  4. /* Lowest common multiple */
  5. unsigned long lcm(unsigned long a, unsigned long b)
  6. {
  7. if (a && b)
  8. return (a * b) / gcd(a, b);
  9. else if (b)
  10. return b;
  11. return a;
  12. }
  13. EXPORT_SYMBOL_GPL(lcm);