https://github.com/torvalds/linux
Raw File
Tip revision: bd0a521e88aa7a06ae7aabaed7ae196ed4ad867a authored by Linus Torvalds on 08 July 2012, 00:23:56 UTC
Linux 3.5-rc6
Tip revision: bd0a521
gcd.c
#include <linux/kernel.h>
#include <linux/gcd.h>
#include <linux/export.h>

/* Greatest common divisor */
unsigned long gcd(unsigned long a, unsigned long b)
{
	unsigned long r;

	if (a < b)
		swap(a, b);
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
EXPORT_SYMBOL_GPL(gcd);
back to top