 Timer is Running

Kth Prime factor of a Number
##### Submissions: 2458   Accuracy: 25.36%   Difficulty: Easy   Marks: 2

Given two numbers n and k, print Kth prime factor among all prime factors of n.
Note: if k > all the count of prime factor of n, then print -1.

Input:
The first line of input contains an integer denoting the no of test cases. Then T test cases follow. Each test case contains two space seperated integers n and k respectively.

Output:
For each test case ouput a simple line containing a single integer denoting kth prime factor of n.

Constraints:
1 <= T <= 100
0 <= N <= 104
1 <= K <= 50

Example:
Input:
2
225 2
81 5
Ouput:
3
-1

Explanation:
Test Case 1:  n=225 and k=2 , Prime factor of 225 are: 3,3,5,5 .Kth prime factor is 3
Test Case 2: n=81 and k=5 , Prime factor of 81 is 3,3,3,3 , since k is greater than all the count of prime
factor, hence we print -1

#### ** For More Input/Output Examples Use 'Expected Output' option **

Author: harshitsidhwa

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.