https://github.com/torvalds/linux
Raw File
Tip revision: 899e3ee404961a90b828ad527573aaaac39f0ab1 authored by Linus Torvalds on 18 October 2011, 04:06:23 UTC
Linux 3.1-rc10
Tip revision: 899e3ee
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