Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
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 :)
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. :)