ProGrad Coding Question

ProGrad Coding Question

Round One Assesment

Statement :

Whenever Kiran's father returns from a business tour, he presents his son a certain number of one rupee coins R and a number of books B. Kiran is always interested in numbers and he usually tries to relate different numbers with respect to different logic. After each instance of receiving the presentation from his father, he makes an entry in his log table. The number entered is the Bth smallest number that perfectly divides the total amount (in rupees) contributed by the coins presented at a given instance. If one such number does not exist, the instance is marked as -1. Write a program to help Kiran to find the appropriate entries to his log book in each of these instances.

Input Format:

The first line of input contains space-separated list of positive integer pair (R B)

Output Format:

Print the number to be entered to mark a given instance of presentation.

Constraints

1<R < 10000000000.

1<B<600

Sample Input:

12 3

Sample Output:

3

Explanation:

R is 12 and B is 3. The factors of 12 are (1, 2, 3, 4, 6, 12) The smallest factor is 1, the second-smallest factor is 2 and the third-smallest factor is 3. Hence, the output is 3.

Solution: