Ad
  • Custom User Avatar

    notice that the question said to return -1 if there is no answer.
    your solution did not take into account this situation , and this is a good hint to realize that for a "m" that has no solution your loop will never stop :)

  • Custom User Avatar

    I agree with fxrbfg .. not every programmer remembers mathematical formulas. and while this is very clever, it should be readable for every "average" programmer so they can understand the solution. :)