title: Modular Exponentiation Power In Modular Arithmetic
signature: def modularExponentiationPowerInModularArithmetic(x: Int, y: Int, p: Int) = {
test_code: import scala.collection.mutable.HashMap
  import scala.collection.immutable.HashSet
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  
  // TESTING CODE 
  // ============================================
  def validateSolution(actual: Int , expected: Int): Boolean = {
      actual.toString == expected.toString
  }
  
  def driver(x: Int, y: Int, p: Int, expected: Int): String = {
      try {
          if (validateSolution(PLACEHOLDER_FN_NAME(x, y, p),expected)) {
              "PASSED"
          } else{
              "FAILED"
          }
      }catch{
          case e: Exception => {e.getClass.getName}
      }
  
  }
  object QuestionEvaluator extends App {
  
      println(s"TEST-0...${driver(
        45, 5, 68, 
        61    
      )}")   
  
  
      println(s"TEST-1...${driver(
        67, 25, 49, 
        18    
      )}")   
  
  
      println(s"TEST-2...${driver(
        26, 91, 44, 
        4    
      )}")   
  
  
      println(s"TEST-3...${driver(
        33, 61, 9, 
        0    
      )}")   
  
  
      println(s"TEST-4...${driver(
        35, 8, 13, 
        3    
      )}")   
  
  
      println(s"TEST-5...${driver(
        68, 41, 5, 
        3    
      )}")   
  
  
      println(s"TEST-6...${driver(
        14, 76, 20, 
        16    
      )}")   
  
  
      println(s"TEST-7...${driver(
        5, 89, 13, 
        5    
      )}")   
  
  
      println(s"TEST-8...${driver(
        23, 42, 45, 
        19    
      )}")   
  
  
      println(s"TEST-9...${driver(
        37, 63, 56, 
        29    
      )}")   
  
  }
  
source_py: def modular_exponentiation_power_in_modular_arithmetic(x, y, p):
      res = 1
      x = (x % p)
      while (y > 0):
          if ((y & 1) == 1):
              res = ((res * x) % p)
          y = (y >> 1)
          x = ((x * x) % p)
      return res
source_cpp: int modular_exponentiation_power_in_modular_arithmetic(int x, unsigned int y, int p) {
    int res = 1;
    x = x % p;
    while ( y > 0 ) {
      if ( y & 1 ) res = ( res * x ) % p;
      y = y >> 1;
      x = ( x * x ) % p;
    }
    return res;
  }