[] Data structure and algorithm study notes - "algorithm notes" -16 greatest common divisor and least common multiple []

Greatest common divisor

int gcd(int a, int b)
{
	return	!b ? a : gcd(b, a%b);
}

The least common multiple
Provided positive integers a and b is the greatest common divisor d, least common multiple is c, then c = a * b / d,In order to prevent overflow, Should be written as a / d * b.

Published 43 original articles · won praise 4 · Views 1207

Guess you like

Origin blog.csdn.net/weixin_42176221/article/details/101923864