/*A Boston number is a composite number, the sum of whose digits is the sum of the digits of its prime factors obtained as a result of prime factorization (excluding 1 ). The first few such numbers are 4,22 ,27 ,58 ,85 ,94 and 121 . For example, 378 = 2 × 3 × 3 × 3 × 7 is a Boston number since 3 + 7 + 8 = 2 + 3 + 3 + 3 + 7. Write a program to check whether a given integer is a Boston number.
Input Format
There will be only one line of input:N , the number which needs to be checked.
Constraints
1 < N < 2,147,483,647 (max value of an integer of the size of 4 bytes)
Output Format
1 if the number is a Boston number. 0 if the number is a not Boston number.
Sample Input
378
Sample Output
1
Explanation
Self Explanatory
*/
#include
using namespace std;
int findPrimeSum(int n)
{
int j;
int sum=0;
for(int i=2;i<n;i++)
{
for(j=2;j<i;j++)
{
if(i%j==0)
{
break;
}
}
if(i==j)
{
sum=sum+i;
}
}
return sum;
}
int findNumSum(int n)
{
int sum;
int no;
while(n>0)
{
no=n%10;
sum=sum+no;
n=n/10;
}
return sum;
}
int main()
{
long int n;
cin>>n;
int x=findPrimeSum(n);
int y=findNumSum(n);
if(x==y)
{
cout<<1;
}
else{
cout<<0;
}
return 0;
}
I am not able to find the approach to solve this question please tell me the approach and what changes I should do in this code