gcd.c 291 B

12345678910111213141516171819
  1. #include <linux/kernel.h>
  2. #include <linux/gcd.h>
  3. #include <linux/module.h>
  4. /* Greatest common divisor */
  5. unsigned long gcd(unsigned long a, unsigned long b)
  6. {
  7. unsigned long r;
  8. if (a < b)
  9. swap(a, b);
  10. while ((r = a % b) != 0) {
  11. a = b;
  12. b = r;
  13. }
  14. return b;
  15. }
  16. EXPORT_SYMBOL_GPL(gcd);