You are viewing a single comment's thread. Return to all comments →
according to me it shouldn't work but if it passed test cases ,then i dont know how .the reason is that consider a number like 73 ,then n%5 should give 3 ,and hence it would redirect to the else statement and print n, whereas it should have printed 75 as we need to consider the next multiple of 5 ,75-73 =2 (<3) .Correct me ,if i am wrong ,anyone. (might be i am wrong too :P ,i developed my solution in my way ,though!)
73 % 5 = 3 and 3 <= 3, so it'll satisfy the else if condition.
Then we have cout << 73 + (5- 73%5) << endl; which simplifies to cout << 73 + 2 << endl;
Why are we checking <=3 and not some other number?