Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Help me about loop invariant of LCM

  1. Mar 5, 2005 #1
    please help me, i was stuck in here 2 days!!!
    algorithm to prove lcm:

    a:=m
    b:=n
    while a != b
    if a < b
    a:= a + m
    else
    b:= b + n

    //postcondition: a is the lcm(m,n)

    what's the loop invariant?I thought it is(not sure):
    lcm(ak, bk) = lcm(ak/m, bk/n) *lcm(m,n)
    I am not sure and also impossible to prove my loop invariant....
     
  2. jcsd
  3. Mar 5, 2005 #2
    Forget it! problem soloved ...

    Forget it! problem soloved ... :smile:
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Help me about loop invariant of LCM
  1. Help me (Replies: 4)

  2. Gcd and lcm (Replies: 59)

Loading...