mirror of
https://github.com/torvalds/linux
synced 2024-11-05 18:23:50 +00:00
69c953c85c
Return the mathematically correct answer when an argument is 0. Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> Cc: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
14 lines
269 B
C
14 lines
269 B
C
#include <linux/kernel.h>
|
|
#include <linux/gcd.h>
|
|
#include <linux/export.h>
|
|
#include <linux/lcm.h>
|
|
|
|
/* Lowest common multiple */
|
|
unsigned long lcm(unsigned long a, unsigned long b)
|
|
{
|
|
if (a && b)
|
|
return (a / gcd(a, b)) * b;
|
|
else
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL_GPL(lcm);
|