Staging
v0.5.1
https://github.com/torvalds/linux
Raw File
Tip revision: bf16200689118d19de1b8d2a3c314fc21f5dc7bb authored by Linus Torvalds on 11 April 2016, 00:58:30 UTC
Linux 4.6-rc3
Tip revision: bf16200
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