brintos

brintos / linux-shallow public Read only

0
0
Text · 482 B · 6e0b2e7 Raw
27 lines · c
1// SPDX-License-Identifier: GPL-2.0-only2#include <linux/compiler.h>3#include <linux/gcd.h>4#include <linux/export.h>5#include <linux/lcm.h>6 7/* Lowest common multiple */8unsigned long lcm(unsigned long a, unsigned long b)9{10	if (a && b)11		return (a / gcd(a, b)) * b;12	else13		return 0;14}15EXPORT_SYMBOL_GPL(lcm);16 17unsigned long lcm_not_zero(unsigned long a, unsigned long b)18{19	unsigned long l = lcm(a, b);20 21	if (l)22		return l;23 24	return (b ? : a);25}26EXPORT_SYMBOL_GPL(lcm_not_zero);27