Check if a Number is Automorphic
Given a positive integer n, return true when the decimal representation of n² ends with every digit of n; otherwise return false. Such a value is called an…
Given a positive integer `n`, return `true` when the decimal representation of `n²` ends with every digit of `n`; otherwise return `false`. Such a value is called an automorphic number. For example, `25² = 625`, which ends with `25`.
- `1 ≤ n ≤ 10^6` - `n` is always a positive integer.
Example 1: input n = 25; output true. 25² = 625, and 625 ends with 25.
Example 2: input n = 7; output false. 7² = 49, which does not end with 7.
Example 3: input n = 76; output true. 76² = 5776, and its final two digits are 76.
Category: Math. Topic: math. Difficulty: Easy. Patterns: math.