Check if a Number is Neon

Given a non-negative integer n, return true if the sum of the decimal digits of n² equals n; otherwise return false. Such a value is called a neon number. For…

Given a non-negative integer `n`, return `true` if the sum of the decimal digits of `n²` equals `n`; otherwise return `false`. Such a value is called a neon number. For example, `9² = 81` and `8 + 1 = 9`.

- `0 ≤ n ≤ 10^6` - `n` is always an integer.

Example 1: input n = 9; output true. 9² is 81 and 8 + 1 equals 9.

Example 2: input n = 0; output true. 0² is 0 and its digit sum is 0.

Example 3: input n = 12; output false. 12² is 144 and 1 + 4 + 4 equals 9, not 12.

Category: Math. Topic: math. Difficulty: Easy. Patterns: math.