Merge tag 'locks-v3.16-2' of git://git.samba.org/jlayton/linux
[linux/fpc-iii.git] / lib / gcd.c
blob3657f129d7b8c5db0bee11a94a97d5d4bf251b52
1 #include <linux/kernel.h>
2 #include <linux/gcd.h>
3 #include <linux/export.h>
5 /* Greatest common divisor */
6 unsigned long gcd(unsigned long a, unsigned long b)
8 unsigned long r;
10 if (a < b)
11 swap(a, b);
13 if (!b)
14 return a;
15 while ((r = a % b) != 0) {
16 a = b;
17 b = r;
19 return b;
21 EXPORT_SYMBOL_GPL(gcd);