PRIME FACTORIZATION SIEVE METHOD

#include
#include
using namespace std;

vector prime_sieve(int *p,int n)
{
p[2]=1;
p[0]=p[1]=0;

vector<int> primes;
for(int i=3;i<=n;i=i+2)
    p[i]=1;
    
for(int i=3;i<=n;i=i+2)
{
    if(p[i]==1)
    {
        for(int j=i*i;j<=n;j=j+i)
            p[j]=0;
    }
}
for(int i=3;i<=n;i=i+2)
{
    if(p[i]==1)
       primes.push_back(i);
}
return primes;

}

vector factorize(vector &primes,int no)
{
vector factors(no,0);
int i=2;
while(i*i<=no)
{
if(no/i==0)
{
factors.push_back(i);
no=no/i;
}
else
i++;
}
if(i!=1)
factors.push_back(no);

return factors;   

}

int main()
{
int n;
cin>>n;
int *p=new int[n];
p[0]={0};

vector<int> primes=prime_sieve(p,n);

int t;
cin>>t;
while(t--)
{
   int no;
   cin>>no;
   vector<int> factors=factorize(primes,no);
   for(int i=0;i<factors.size();i++)
   {
       cout<<factors[i]<<" ";
   }
}

}
Can u plz tell the mistake in my code.Its not giving the req. output

hi @Mukul-Shane-1247687648773500,
refer this : https://ide.codingblocks.com/s/656705

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.

sir this code that u have given is wrong.Itsgiving wrong ouput

@Mukul-Shane-1247687648773500,
u wanted factors right? its giving that only

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.