diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gcd.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -9,6 +9,9 @@ unsigned long gcd(unsigned long a, unsigned long b) | |||
9 | 9 | ||
10 | if (a < b) | 10 | if (a < b) |
11 | swap(a, b); | 11 | swap(a, b); |
12 | |||
13 | if (!b) | ||
14 | return a; | ||
12 | while ((r = a % b) != 0) { | 15 | while ((r = a % b) != 0) { |
13 | a = b; | 16 | a = b; |
14 | b = r; | 17 | b = r; |