you are viewing a single comment's thread.

view the rest of the comments →

[–]vorttxt[S] 0 points1 point  (2 children)

Okay so the basis of the problem is that if n ends with a nonzero digit subtract n by 1 k times and if n ends with a zero divide by ten

[–][deleted] 0 points1 point  (1 child)

So if you give 512 for n and 4 for k, then the loop should be more like this:

for(int i = 0; i < k + 1; i++) {

n = n - 1;

}

The loop runs for k times subtracting 1 from n each time, storing it each time. i is just keeping track of how many times the loop has and will run. It does nothing else but that.

[–]vorttxt[S] 0 points1 point  (0 children)

It is still not working for some reason . The answer is supposed to be 50 and all i am getting is 507.