(
unsigned intx,
unsigned inty) {
29 unsigned inttemp = x / y;
30 return gcd(y, x - temp * y);
34 unsigned inttemp = y / x;
35 return gcd(x, y - temp * x);
43unsigned int lcm(
unsigned intx,
unsigned inty) {
44 returnx /
gcd(x, y) * y;
52assert(((
void)
"LCM of 5 and 10 is 10 but lcm function gives a different " 55std::cout <<
"First assertion passes: LCM of 5 and 10 is "<<
lcm(5, 10)
59assert(((
void)
"LCM of 2 and 3 is 6 but lcm function gives a different " 62std::cout <<
"Second assertion passes: LCM of 2 and 3 is "<<
lcm(2, 3)
67assert(((
void)
"LCM of 987654321 and 987654321 is 987654321 but lcm function" 68 " gives a different result.\n",
69 lcm(987654321, 987654321) == 987654321));
70std::cout <<
"Third assertion passes: LCM of 987654321 and 987654321 is " 71<<
lcm(987654321, 987654321)
unsigned int gcd(unsigned int x, unsigned int y)
unsigned int lcm(unsigned int x, unsigned int y)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4