Can you please tell me that what is wrong with this code?

#include
#include<math.h>
using namespace std;
void Boston(long long n)
{
int temp =0;
int x = n;
while(n%2 == 0)
{
temp = temp+2;
n = n/2;
}
for(int i=3;i<=sqrt(n);i=i+2)
{
while(n%i == 0)
{
temp = temp+i;
n=n/i;
}
}
if(n>2)
{
temp = temp+n;
}
int val =0;
int i;
while(x>0)
{
i=x%10;
val = i+val;
x = x/10;
}
if(temp == val )
{
cout<<1<<endl;
}
else
{
cout<<0<<endl;
}

}
int main()
{
long long n;
cin>>n;
Boston(n);
return 0;
}

hi @deepshreyamishra301_1918130c8477386b,
it says sum of digits of factors not sum of factors
to correct --> everytime u get a factor sum all its digits dont directly add

here’s corrected code https://ide.codingblocks.com/s/660387

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.