Check if a Number is a Kaprekar Number
Given a positive integer n with d decimal digits, square n and split the square so the right part contains exactly d digits. Return true if the right part is…
Given a positive integer `n` with `d` decimal digits, square `n` and split the square so the right part contains exactly `d` digits. Return `true` if the right part is positive and the two parts add to `n`; otherwise return `false`. A missing left part is treated as zero.
- `1 ≤ n ≤ 10^4` - `n` is always a positive integer.
Example 1: input n = 45; output true. 45² = 2025, and 20 + 25 = 45.
Example 2: input n = 10; output false. 10² = 100, and the two-digit right part is 00, which is not positive.
Category: Math. Topic: math. Difficulty: Easy. Patterns: math.