• Post Reply Bookmark Topic Watch Topic
  • New Topic

How does it work for this code?  RSS feed

 
theeradetch sillapacharoein
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



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.
 
Carey Brown
Saloon Keeper
Posts: 3323
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sometimes instrumenting code with prints helps.

 
theeradetch sillapacharoein
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Carey Brown wrote:Sometimes instrumenting code with prints helps.




FANTASTIC!!!

Thank you indeed for your help


 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!