Https://ide.codingblocks.com/s/373481

plz make the required changes and tell the error in logic

There are 2 reasons why your test cases are not getting passed:

  1. Because of you calculating your is not correct way to calculate mode.

return ((a%c+ modulo(a,b-1,c)%c)%c);

  1. Also try using long long int instead of int, as test cases are very large in number.

If you want to do it using recursion you can do it, just take reference from this

pls give a brief explanation of ur code.

It’s same as of yours just different in calculating the mode, do you want explanation of how i calculate the mode of these three numbers or anything else?

yes i want to know that only basically what was the error in my logic

Instead of this

You should have done this

((a%c * modulo(a,b-1,c)%c)%c);

That’s it

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.