]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - lib/gcd.c
Merge tag 'mmc-v4.5-rc2' of git://git.linaro.org/people/ulf.hansson/mmc
[mirror_ubuntu-bionic-kernel.git] / lib / gcd.c
CommitLineData
d2829224
FF
1#include <linux/kernel.h>
2#include <linux/gcd.h>
8bc3bcc9 3#include <linux/export.h>
d2829224
FF
4
5/* Greatest common divisor */
6unsigned long gcd(unsigned long a, unsigned long b)
7{
8 unsigned long r;
9
10 if (a < b)
11 swap(a, b);
e9687567
DB
12
13 if (!b)
14 return a;
d2829224
FF
15 while ((r = a % b) != 0) {
16 a = b;
17 b = r;
18 }
19 return b;
20}
21EXPORT_SYMBOL_GPL(gcd);