Created
March 9, 2011 12:48
-
-
Save tormaroe/862126 to your computer and use it in GitHub Desktop.
Greatest Common Devisor implementation from the Linux source code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment