BOSTON NUMBERS PROBLEM

tell the errors in code of this Boston numbers problem

@Mayankrocks,

Change your if statement inside printPrimeFactors,

if (n >2) {
sum=sum+n;
}

to,

if (n >1) {
sum=sum+n;
}

2 test cases are still not passing

@Mayankrocks,

There is one more error, you are adding like this,

sum= sum + i;

But the question wants to add the digits of its factor, so if the factor is 23 we don’t need to add 23 instead we would add 2+3 = 5 to the answer.

sum = sum + sum_of_its_digit(i);
Similarly for, sum = sum + sum_of_its_digit(n);;

can u send the code?

@Mayankrocks,

You can find the implementation below,
BOSTON NUMBER

it is still failing two test cases

@Mayankrocks,

Did you submit it? I can’t see your latest submission.

yes and now i submitted it again and it is working for all test cases

1 Like

@Mayankrocks,

Is the implementation clear now?

yes
send feedback link

1 Like

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.