We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Interesting point here is in this problem when your prime factor also would of equal to 2 or more then you have to sum its digits also.So your solution may goes like this
include
using namespace std;
int digitSum(int n)
{
int sum = 0;
while(n)
{
sum += n%10;
n /= 10;
}
return sum ;
}
Identify Smith Numbers
You are viewing a single comment's thread. Return to all comments →
Interesting point here is in this problem when your prime factor also would of equal to 2 or more then you have to sum its digits also.So your solution may goes like this
include
using namespace std; int digitSum(int n) { int sum = 0; while(n) { sum += n%10; n /= 10; } return sum ; }
int main() { int n ; cin>>n ;
}