Please correct my code

#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int primefactor(int n)
{
int i,j=0,count;
vector<pair<int,int>>factor(10000);

for(i=2;i*i<=n;i++)
{
    if(n%i==0)
    {
        count=0;
        while(n%i==0)
        {
            n=n/i;
            count++;
        }

        factor[j]=make_pair(i,count);
        j++;
    }
}

if(n!=1)
{
    factor[j]=make_pair(n,1);
    j++;
}

return factor;

}

int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);

int n,i,j=0,count;
cin>>n;

vector<pair<int,int>>factor2(10000);

factor2=primefactor(n);

for(i=0;i<j;i++)
{
    cout<<factor[i].first<<"^"<<factor[i].second<<" ";
}


return 0;

}

Hey,
You’ve to mention the return type of the function as vector<pair<int, int>> instead of int, that’s where the error is.

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.