https://github.com/torvalds/linux
Raw File
Tip revision: 6221f222c0ebf1acdf7abcf927178f40e1a65e2a authored by Linus Torvalds on 06 April 2011, 01:30:43 UTC
Linux 2.6.39-rc2
Tip revision: 6221f22
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