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.
Identify Smith Numbers
Identify Smith Numbers
Sort by
recency
|
129 Discussions
|
Please Login in order to post a comment
int parse_int(char* str) { char* endptr; int value = strtol(str, &endptr, 10);
} int sum_of_digits(int num) {
} int sum_of_prime_factors_digits(int num) {
} int solve(int n) {
}
My python solution (I'm new to python!):
python solution:
My solution using C++. Hope you have a good day
#include <bits/stdc++.h> using namespace std; long long ndigits(unsigned long long n){ long long dem=0; while(n!=0){ dem+=n%10; n/=10; } return dem; } long long primeFactorsDigitsSum(unsigned long long n) { long long dem=0; for(int i = 2; i <= n; i++){ while(n % i == 0){ dem+=ndigits(i); n /= i; } } return dem; } int main(){ long long n; cin>>n; if (primeFactorsDigitsSum(n)==ndigits(n)){ cout<<1; return 0; } cout<<0; return 0; }