Modular Expression

Implement pow(A, B) % C.

In other words, given A, B and C,
find (AB)%C.

Input : A = 2, B = 3, C = 3
Return : 2 
2^3 % 3 = 8 % 3 = 2

PROBLEM APPROACH :

Complete solution in the hint.

Interview Code Editor
Hints
  • Complete Solution
2447 successful submissions.
Click here to jump start your coding interview preparation