https://github.com/torvalds/linux
Raw File
Tip revision: bfe01a5ba2490f299e1d2d5508cbbbadd897bbe9 authored by Linus Torvalds on 05 October 2014, 19:23:04 UTC
Linux 3.17
Tip revision: bfe01a5
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);

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