Modular exponentiation test cases

few test cases are wrong. help me find the bug. https://ide.codingblocks.com/s/88068

As the question suggests, we have to use fast exponentiation for power function, We can use exponentiation by squaring method Algo. is as follows:-

- A^p = A, if p=1
- A^p = A * A^(p-1), if p is odd
- A^p = X*X, where X = A^(p/2), otherwise

use recursion to achieve this.

The maximum value a and b can have is 100000.
What you are are doing is a^b i.e. 100000^100000.

Is there any datatype available to store this big(infinitely big) value?
No, is the answer.

This, is the reason you are getting wrong output. If you want to verify this, then I would suggest you to print ans and see what it print.

Think of a different way to calculate modular exponential.

Hope, this would help.
If you still have doubts, feel free to ask.

I am marking this doubt as resolved as you have not replied to this thread for nine days.
In case, you still have some doubts regarding the same problem, you can reopen this doubt.

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.