The Smith Number
HardAcc. 79.2%
+40 XP 20
Digital Harmony
A composite number is a Smith Number if the sum of its digits equals the sum of the digits of its prime factors (excluding 1). Example: 4937775 Prime Factors: 3, 5, 5, 65837 $ o$ digit sums match!
The Assignment
Your function receives a parameter num.
- Check if
numis composite (not prime). - Calculate the sum of digits of
num. - Find all prime factors of
num. - Calculate the sum of digits of all those prime factors combined.
- Print "true" if the sums match, else "false".
01EXAMPLE 1
Input
num = 666Output
trueExplanation: Digits 6+6+6=18. Factors 2, 3, 3, 37. Digit sums: 2+3+3+(3+7)=18.
Constraints
- Must use loops for factoring and digit summing.
- Strict comparison check.
MathLoopsDigits
JavaScriptSystem handles I/O — write your function only
Loading...
3 Hidden
Input Arguments
num666
Expected Output
true
Click RUN to test your solution