A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://TheAlgorithms.github.io/C-Plus-Plus/d4/d21/least__common__multiple_8cpp_source.html below:

TheAlgorithms/C++: math/least_common_multiple.cpp Source File

Go to the documentation of this file. 16unsigned int gcd

(

unsigned int

x,

unsigned int

y) {

29 unsigned int

temp = x / y;

30 return gcd

(y, x - temp * y);

34 unsigned int

temp = y / x;

35 return gcd

(x, y - temp * x);

43unsigned int lcm

(

unsigned int

x,

unsigned int

y) {

44 return

x /

gcd

(x, y) * y;

52

assert(((

void

)

"LCM of 5 and 10 is 10 but lcm function gives a different " 55

std::cout <<

"First assertion passes: LCM of 5 and 10 is "

<<

lcm

(5, 10)

59

assert(((

void

)

"LCM of 2 and 3 is 6 but lcm function gives a different " 62

std::cout <<

"Second assertion passes: LCM of 2 and 3 is "

<<

lcm

(2, 3)

67

assert(((

void

)

"LCM of 987654321 and 987654321 is 987654321 but lcm function" 68 " gives a different result.\n"

,

69 lcm

(987654321, 987654321) == 987654321));

70

std::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