theeradetch sillapacharoein

Greenhorn

Posts: 5

posted 3 months ago

let me input x = 5 y = 1

while(y != 0) <<<< how the process will be if we got y= 1 and then go to the bottom line

{

int t = y; <<<<< I thought that t = 1 is'not right?

y = x%y; <<<<< y = 5%1 so y = 0 i getting stunned

x = t; <<<< x equal = 1 because t =y and x also

}

gcd = x;

lcm = (a*b) / gcd;

//

i try figure it out but i can not get it . please, explain for me how does it work ?

please also provide example. thank you.

let me input x = 5 y = 1

while(y != 0) <<<< how the process will be if we got y= 1 and then go to the bottom line

{

int t = y; <<<<< I thought that t = 1 is'not right?

y = x%y; <<<<< y = 5%1 so y = 0 i getting stunned

x = t; <<<< x equal = 1 because t =y and x also

}

gcd = x;

lcm = (a*b) / gcd;

//

i try figure it out but i can not get it . please, explain for me how does it work ?

please also provide example. thank you.