Skip to content

Commit

Permalink
lib/lcm.c: lcm(n,0)=lcm(0,n) is 0, not n
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Villemoes authored and torvalds committed Dec 11, 2014
1 parent 74a5fef commit 69c953c
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/lcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

0 comments on commit 69c953c

Please sign in to comment.