Finding the prime exponent of a number k in factorial of n

Can anyone tell me where is the problem in the solution. 1 test case is getting failed.
Approach : finding all the prime factors of k and storing it in an array. O(sqrt(k)) time complexity. Finding the maximum of this array which will guide the answer and then finding the prime exponent of this number in n!.

code :
https://pastebin.com/21p6K3PQ