title: K Th Prime Factor Given Number
signature: def k_th_prime_factor_given_number(n, k):
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;
  }
question_info.test_code: import array
  import bisect
  import collections
  import datetime
  import functools
  import heapq
  import itertools
  import math
  import queue
  import re
  import string
  import sys
  from typing import Any, Dict, List, Optional, Set
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  def validate_solution(actual, expected):
      return abs(actual - expected) < 1e-06
  
  def driver(n, k, expected):
      try:
          if validate_solution(PLACEHOLDER_FN_NAME(
              n, k),
              expected
          ):
              return "PASSED"
          return "FAILED"
      except Exception as exception_obj:
          return type(exception_obj).__name__
      
  if __name__ == "__main__":
      result = driver(94, 0, -1.0)
      print(f"TEST-0...{result}")
  
      result = driver(99, 1, 3.0)
      print(f"TEST-1...{result}")
  
      result = driver(64, 3, 2.0)
      print(f"TEST-2...{result}")
  
      result = driver(27, 3, 3.0)
      print(f"TEST-3...{result}")
  
      result = driver(24, 4, 3.0)
      print(f"TEST-4...{result}")
  
      result = driver(84, 6, -1.0)
      print(f"TEST-5...{result}")
  
      result = driver(69, 98, -1.0)
      print(f"TEST-6...{result}")
  
      result = driver(69, 39, -1.0)
      print(f"TEST-7...{result}")
  
      result = driver(22, 60, -1.0)
      print(f"TEST-8...{result}")
  
      result = driver(39, 57, -1.0)
      print(f"TEST-9...{result}")
  
      sys.exit(0)
question_info.test_case_ids: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
question_info.entry_fn_name: k_th_prime_factor_given_number
question_info.test_list: [{"idx": 0, "outputs": -1, "inputs": {"n": 94, "k": 0}}, {"idx": 1, "outputs": 3, "inputs": {"n": 99, "k": 1}}, {"idx": 2, "outputs": 2, "inputs": {"n": 64, "k": 3}}, {"idx": 3, "outputs": 3, "inputs": {"n": 27, "k": 3}}, {"idx": 4, "outputs": 3.0, "inputs": {"n": 24, "k": 4}}, {"idx": 5, "outputs": -1, "inputs": {"n": 84, "k": 6}}, {"idx": 6, "outputs": -1, "inputs": {"n": 69, "k": 98}}, {"idx": 7, "outputs": -1, "inputs": {"n": 69, "k": 39}}, {"idx": 8, "outputs": -1, "inputs": {"n": 22, "k": 60}}, {"idx": 9, "outputs": -1, "inputs": {"n": 39, "k": 57}}]
question_info.entry_cls_name: Solution