Boston Number wrong answer in 3 testcases

For 3 of the test cases, my code fails

#include
#include
#include<math.h>
using namespace std;

int digitSum(int a)
{
int sum = 0;
while(a != 0)
{
sum += a%10;
a = a/10;
}

return sum;

}

bool isPrime(int n)
{
if (n <= 1)
return false;
if (n <= 3)
return true;

if (n % 2 == 0 || n % 3 == 0)
    return false;

for (int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0)
        return false;

return true;

}

int main() {

int a;
int sum1=0,sum2=0;
vector<int> b;

cin>>a;

for(int i=2;i<=sqrt(a);i++)
{
    if(isPrime(i))
    {
        int x=0;
        if(a%i == 0)
        {
            x = a/i;
            b.push_back(i);
            while(x>1)
            {
                if(x%i == 0)
                {
                    b.push_back(i);
                }else
                {
                    x=0;
                }
                x = x/i;
            }
    }else
       continue;
    }else
       continue;
}

sum1 = digitSum(a);

for(int j=0;j<b.size();j++)
{
    sum2 += digitSum(b[j]);
}

if(sum1 == sum2)
    cout<<1;
else
    cout<<0;

return 0;

}

Please help me, where I am going wrong.
I wasted a complete hour in debugging the code.

could u please paste the code in coding blocks ide.
so that i have proper readability

all factors are not added to the vector b
so the digitsum is not working well for u

while(num%2 == 0){
vec.push_back(2);
num>>=1;
}
for(int i = 3; i <= sqrt(num) ; i+=2){
while((num%i) == 0){
vec.push_back(i);
num/=i;
}
}
if(num > 2)
vec.push_back(num);

Update the prime factor code then try running it against test cases

sorry can’t reply due to network problem.Now I have pasted the code in ide

okay
do ask if u have any doubts…

The code worked fine thanks. I have just one doubt why the for loop is incremented by 2 and not by 1.

because we have already removed all multiple of 2
so basically we are iterating over the odd values 3 5 7…