diff options
Diffstat (limited to 'lib/gcd.c')
-rw-r--r-- | lib/gcd.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/gcd.c b/lib/gcd.c new file mode 100644 index 000000000000..f879033d9822 --- /dev/null +++ b/lib/gcd.c | |||
@@ -0,0 +1,18 @@ | |||
1 | #include <linux/kernel.h> | ||
2 | #include <linux/gcd.h> | ||
3 | #include <linux/module.h> | ||
4 | |||
5 | /* Greatest common divisor */ | ||
6 | unsigned long gcd(unsigned long a, unsigned long b) | ||
7 | { | ||
8 | unsigned long r; | ||
9 | |||
10 | if (a < b) | ||
11 | swap(a, b); | ||
12 | while ((r = a % b) != 0) { | ||
13 | a = b; | ||
14 | b = r; | ||
15 | } | ||
16 | return b; | ||
17 | } | ||
18 | EXPORT_SYMBOL_GPL(gcd); | ||