Check if a Number is a Smith Number
Given a positive integer n, return true if n is composite and the sum of its decimal digits equals the sum of the decimal digits of its prime factors, counted…
Given a positive integer `n`, return `true` if `n` is composite and the sum of its decimal digits equals the sum of the decimal digits of its prime factors, counted with multiplicity. For example, `58 = 2 × 29`; both `5 + 8` and `2 + 2 + 9` equal 13.
- `1 ≤ n ≤ 10^6` - `n` is always a positive integer.
Example 1: input n = 58; output true. 58 is composite, and 5 + 8 equals 2 + 2 + 9.
Example 2: input n = 13; output false. A prime number is not a Smith number.
Category: Math. Topic: math. Difficulty: Easy. Patterns: math.