Commit 69c953c8 authored by Rasmus Villemoes's avatar Rasmus Villemoes Committed by Linus Torvalds

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: default avatarRasmus Villemoes <>
Cc: Martin K. Petersen <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 74a5fef7
......@@ -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;
return 0;
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment