Merge remote-tracking branch 'upstream/master' into kvm-devel
[linux-2.6/kvm.git] / lib / gcd.c
blobf879033d98229450a7a88d891c16319cc213f134
1 #include <linux/kernel.h>
2 #include <linux/gcd.h>
3 #include <linux/module.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);
12 while ((r = a % b) != 0) {
13 a = b;
14 b = r;
16 return b;
18 EXPORT_SYMBOL_GPL(gcd);