title: K Th Prime Factor Given Number
signature: def kThPrimeFactorGivenNumber(n: Int, k: Int) = {
test_code: import scala.collection.mutable.HashMap
  import scala.collection.immutable.HashSet
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  
  // TESTING CODE 
  // ============================================
  def validateSolution(actual: Float , expected: Float): Boolean = {
      (actual - expected).abs < 1e-06F
  }
  
  def driver(n: Int, k: Int, expected: Float): String = {
      try {
          if (validateSolution(PLACEHOLDER_FN_NAME(n, k),expected)) {
              "PASSED"
          } else{
              "FAILED"
          }
      }catch{
          case e: Exception => {e.getClass.getName}
      }
  
  }
  object QuestionEvaluator extends App {
  
      println(s"TEST-0...${driver(
        94, 0, 
        -1.0F    
      )}")   
  
  
      println(s"TEST-1...${driver(
        99, 1, 
        3.0F    
      )}")   
  
  
      println(s"TEST-2...${driver(
        64, 3, 
        2.0F    
      )}")   
  
  
      println(s"TEST-3...${driver(
        27, 3, 
        3.0F    
      )}")   
  
  
      println(s"TEST-4...${driver(
        24, 4, 
        3.0F    
      )}")   
  
  
      println(s"TEST-5...${driver(
        84, 6, 
        -1.0F    
      )}")   
  
  
      println(s"TEST-6...${driver(
        69, 98, 
        -1.0F    
      )}")   
  
  
      println(s"TEST-7...${driver(
        69, 39, 
        -1.0F    
      )}")   
  
  
      println(s"TEST-8...${driver(
        22, 60, 
        -1.0F    
      )}")   
  
  
      println(s"TEST-9...${driver(
        39, 57, 
        -1.0F    
      )}")   
  
  }
  
source_py: def k_th_prime_factor_given_number(n, k):
      while ((n % 2) == 0):
          k = (k - 1)
          n = (n / 2)
          if (k == 0):
              return 2
      i = 3
      while (i <= math.sqrt(n)):
          while ((n % i) == 0):
              if (k == 1):
                  return i
              k = (k - 1)
              n = (n / i)
          i = (i + 2)
      if ((n > 2) and (k == 1)):
          return n
      return (- 1)
source_cpp: int k_th_prime_factor_given_number(int n, int k) {
    while ( n % 2 == 0 ) {
      k --;
      n = n / 2;
      if ( k == 0 ) return 2;
    }
    for ( int i = 3;
    i <= sqrt ( n );
    i = i + 2 ) {
      while ( n % i == 0 ) {
        if ( k == 1 ) return i;
        k --;
        n = n / i;
      }
    }
    if ( n > 2 && k == 1 ) return n;
    return - 1;
  }