What happens when you step through the debugger?

Write down the values of a,b,c, and n during each post. You will soon see the problem. If you don't then post the list of numbers and we can go through it....