Introduction
Let's take the number 180
. This is an interesting number because the sum of digits of this number is equal to:
1 + 8 + 0 = 9
And the squared version of this number, or:
180² = 32400 > 3 + 2 + 4 + 0 + 0 = 9
These are both 9. The sum of digits of the original number and the squared number are the same. Of course, this is also found at OEIS: A058369.
Task
Given a non-negative integer n
, output the n
th positive number with this condition.
Test cases (zero-indexed)
Input > Output
0 > 1
1 > 9
2 > 10
3 > 18
4 > 19
5 > 45
6 > 46
7 > 55
8 > 90
9 > 99
10 > 100
11 > 145
12 > 180
13 > 189
14 > 190
15 > 198
16 > 199
17 > 289
18 > 351
19 > 361
The input can also be 1-indexed if that fits you better.
This is code-golf, so the submission with the least amount of bytes wins!
^₂;?{ẹ+}ᵛ
\$\endgroup\$