Which case is missing in this code?

#include
using namespace std;
void boston( int N){
int primefactor = 0;
int K = N;
int i = 2;
while( i <= N ){
if(N % i == 0 ){
if( i ==2 ){
primefactor += i;
}
else if( i % 2 != 0){
primefactor += i;
}
//cout << primefactor << endl;
N = N / i;
}
else{
i++;
}
}
int digitsum = 0;
while( K > 0 ){
int digit = K%10;
digitsum += digit;
K = K/ 10;
}
if( digitsum == primefactor){
cout << “1”;
}
else{
cout << “0”;
}
}
int main() {
int n;
cin>>n;
boston(n);
return 0;
}

hi @akki56756_bab14f919dbad123
The Question is Very Simple but needs a little extra concentration. As many students do not consider that in the Question it said the sum of digits of the given number is Equals to the sum of digits of its prime numbers is equal only when the number is Boston number.
For e.g…, n = 22
Prime Factors = 2 x 11
Sum of Digits = 2 + 2 = 4
Sum of Digits of Factors = 2 + (1 + 1) -> 4
Hence it is a Boston number.

Algorithm
  1. Generate All prime Factors of the number.
  2. Write a Function that calculates the sum of digits of passed number.
  3. Pass each generated Prime Factor to this digits sum function till you can generate prime factors.
  4. At last equate your sum with the sum of digits of given number.
    4.1 If yes print 1.
    4.2 otherwise print 0.

Note -> Make your code a little Efficient otherwise you will get TLE with brute force approach. By making code efficient is either you need to make your prime factor generator efficient or prime checker efficient in order to pass the test cases.

refer this code -->

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.