Blame view
lib/gcd.c
313 Bytes
d28292246 lib: add lib/gcd.c |
1 2 |
#include <linux/kernel.h> #include <linux/gcd.h> |
8bc3bcc93 lib: reduce the u... |
3 |
#include <linux/export.h> |
d28292246 lib: add lib/gcd.c |
4 5 6 7 8 9 10 11 |
/* Greatest common divisor */ unsigned long gcd(unsigned long a, unsigned long b) { unsigned long r; if (a < b) swap(a, b); |
e96875677 lib/gcd.c: preven... |
12 13 14 |
if (!b) return a; |
d28292246 lib: add lib/gcd.c |
15 16 17 18 19 20 21 |
while ((r = a % b) != 0) { a = b; b = r; } return b; } EXPORT_SYMBOL_GPL(gcd); |