lib/lcm.c: lcm(n,0)=lcm(0,n) is 0, not n

Return the mathematically correct answer when an argument is 0.

Signed-off-by: Rasmus Villemoes <[email protected]>
Cc: Martin K. Petersen <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
Rasmus Villemoes authored and Linus Torvalds committed 2014-12-10 17:41:11 -08:00
1 parent 74a5fef7cb
commit 69c953c85c
1 file changed
+2 -4
+2 -4
View File
@@ -8,9 +8,7 @@ unsigned long lcm(unsigned long a, unsigned long b)
{
if (a && b)
return (a / gcd(a, b)) * b;
else if (b)
return b;
return a;
else
return 0;
}
EXPORT_SYMBOL_GPL(lcm);