Well, what about what I suggested? Did you display the values of i and (b-1)-i, and did they match what you expected?

Of course I could just debug it for you and give you the answer but you learn nothing that way. This way you learn to debug, and since 90% of programming is debugging this is by far the much greater skill. Any code monkey can knock out code but it takes skill to debug.

I see in fact you've completely ignored my previous post because you've still got "i=i++". Perhaps you think I don't know what I'm talking about (hint: eyes left, see what it says under my nick. Maybe I do...)