treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / lib / math / lcm.c
blob6e0b2e7367007db3a7a1edaa148f2b08bedcc1c6
1 // SPDX-License-Identifier: GPL-2.0-only
2 #include <linux/compiler.h>
3 #include <linux/gcd.h>
4 #include <linux/export.h>
5 #include <linux/lcm.h>
7 /* Lowest common multiple */
8 unsigned long lcm(unsigned long a, unsigned long b)
10 if (a && b)
11 return (a / gcd(a, b)) * b;
12 else
13 return 0;
15 EXPORT_SYMBOL_GPL(lcm);
17 unsigned long lcm_not_zero(unsigned long a, unsigned long b)
19 unsigned long l = lcm(a, b);
21 if (l)
22 return l;
24 return (b ? : a);
26 EXPORT_SYMBOL_GPL(lcm_not_zero);