Blame view
lib/lcm.c
441 Bytes
6016daed5
|
1 |
#include <linux/compiler.h> |
2cda2728a
|
2 |
#include <linux/gcd.h> |
8bc3bcc93
|
3 |
#include <linux/export.h> |
72d39508e
|
4 |
#include <linux/lcm.h> |
2cda2728a
|
5 6 7 8 9 |
/* Lowest common multiple */ unsigned long lcm(unsigned long a, unsigned long b) { if (a && b) |
74a5fef7c
|
10 |
return (a / gcd(a, b)) * b; |
69c953c85
|
11 12 |
else return 0; |
2cda2728a
|
13 14 |
} EXPORT_SYMBOL_GPL(lcm); |
e9637415a
|
15 16 17 18 19 20 21 22 23 24 25 |
unsigned long lcm_not_zero(unsigned long a, unsigned long b) { unsigned long l = lcm(a, b); if (l) return l; return (b ? : a); } EXPORT_SYMBOL_GPL(lcm_not_zero); |