Back to home page

LXR

 
 

    


0001 #include <linux/compiler.h>
0002 #include <linux/gcd.h>
0003 #include <linux/export.h>
0004 #include <linux/lcm.h>
0005 
0006 /* Lowest common multiple */
0007 unsigned long lcm(unsigned long a, unsigned long b)
0008 {
0009     if (a && b)
0010         return (a / gcd(a, b)) * b;
0011     else
0012         return 0;
0013 }
0014 EXPORT_SYMBOL_GPL(lcm);
0015 
0016 unsigned long lcm_not_zero(unsigned long a, unsigned long b)
0017 {
0018     unsigned long l = lcm(a, b);
0019 
0020     if (l)
0021         return l;
0022 
0023     return (b ? : a);
0024 }
0025 EXPORT_SYMBOL_GPL(lcm_not_zero);