tell the errors in code of this Boston numbers problem
BOSTON NUMBERS PROBLEM
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
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?
it is still failing two test cases
yes and now i submitted it again and it is working for all test cases
yes
send feedback link
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.