What's Wrong with my Approach?

I need to know What’s Wrong with my Approach ?
Link to Code : https://ide.codingblocks.com/s/189484

@O17LPOLA020011 Which case are you failing? I can see that your code is working fine.

gives wrong answer for all test cases

@O17LPOLA020011 Try taking the modulus properly. It is possible that you are not calculating the
modulus properly.

ok, let me give it a try

I appreciate your observation but it is wrong. Try to again dry run the code so that you will be able to get the error, debug the code and make it an AC.

Great! All the best.

My Approach is correct, right ?
Or do I need to try some other approach ?

After a bit of debugging, finally got AC

@O17LPOLA020011 Good Job Dude. You must be proud of yourself.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.