https://github.com/torvalds/linux
Raw File
Tip revision: 521cb40b0c44418a4fd36dc633f575813d59a43d authored by Linus Torvalds on 15 March 2011, 01:20:32 UTC
Linux 2.6.38
Tip revision: 521cb40
gcd.c
#include <linux/kernel.h>
#include <linux/gcd.h>
#include <linux/module.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