For future reference, please wrap your code in the tags.

I suggest writing down the math on a piece of paper, going through the algorithm the code executes a step at a time. As hint, 0 time...