https://github.com/torvalds/linux
Raw File
Tip revision: 220bf991b0366cc50a94feede3d7341fa5710ee4 authored by Linus Torvalds on 20 March 2010, 01:17:57 UTC
Linux 2.6.34-rc2
Tip revision: 220bf99
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