Question: I need C code for this problem Jamie has n candies. She is willing to share m of them with Mark, where m is the
I need C code for this problem
Jamie has n candies. She is willing to share m of them with Mark, where m is the pth smallest factor of n (i.e., the pth smallest long integer to divide n with no remainder). For example, the factors of n = 8 are (1, 2, 4, 8); if p = 3, then Jamie shares m = 4 candies with Mark.
Complete the function in the editor below. It has two parameters:
Name Type Description
n long integer The number of candies Jamie has.
p long integer Used to determine the pth smallest factor of n.
The function must return a long integer denoting m (i.e., the number of candies Jamie gives Mark). If no pth smallest factor exists, return 0 instead. Input Format The first line contains a long integer denoting n.
The second line contains a long integer denoting p. Constraints 1 < n < 1015
1 < p < 109
Output Format Return a long integer denoting m (i.e., the number of candies Jamie gives Mark). If no pth smallest factor exists, return 0 instead.
Sample Case 0 Sample Input 10 3
Sample Output
5
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
