I am getting one wrong answer

I have already used the prime factorization, but it is failing one test case. Please help with the same.

#include<bits/stdc++.h>
using namespace std;
#define ll long long
int comp(int n,int x){
    int k = x;
    int ans = 0;
        while(n/k > 0){
            ans = ans + (n/k);
            k = k*x;
        }
    return ans;
}
int prime(int n, int k){
    int ans = INT_MAX;
    for(int i=2;i*i<=k;i++){
        if(k%i == 0){
            int cnt = 0;
            while(k%i == 0){
                k = k/i;
                cnt++;
            }
            int x = comp(n,i);
            x = x/cnt;
            ans = min(ans,x);
        }
    }
    if(k!=1){
        ans = min(ans,comp(n,k));
    }
    return ans;
}
int main(){
    int t;
    cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        cout<<prime(n,k)<<endl;
    }
    return 0;
}

please help with the same.

@shivama_700 Here https://ide.codingblocks.com/s/203073 I corrected your code please see.

where was the fault?, I don’t need code, just provide a hint, why my code was failing.

@shivama_700 Just make your ‘k’ long long to avoid overflow and the it works fine.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.