[Question]
  [
### 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](https://oeis.org/search?q=1%2C+9%2C+10%2C+18%2C+19%2C+45+%2C46%2C+55%2C+90%2C+99%2C+100&language=english&go=Search).
### 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](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the submission with the least amount of bytes wins!
  
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~10~~ ~~9~~ 8 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
µNÐn‚1öË
```
1-indexed.
-1 byte thanks to *@Emigna* by removing the implicit `½` (increase `counter_variable` after every iteration) at the end  
-1 byte thanks to *@Grimy* removing the duplicated `SO` by using `‚1ö`
[Try it online.](https://tio.run/##yy9OTMpM/f//0Fa/wxPyHjXMMjy87XD3///mAA)
**Explanation:**
```
µ         # Loop while the counter_variable is not equal to the (implicit) input yet:
 NÐ       #  Push the 0-based loop index three times
   n      #  Take the square of this index
          #   i.e. 180 → 32400
    ‚     #  Pair it with the index
          #   i.e. 180 and 32400 → [180,32400]
     1ö   #  Convert both numbers from base-1 to base-10, which basically sums the digits
          #   i.e. [180,32400] → [9,9]
       Ë  #  Check if both sums are equal
          #   i.e. [9,9] → 1 (truthy)
          #  (if they are: implicitly increase the counter_variable by 1)
          # (after the loop: implicitly print the top of the stack, which is the remaining
          #  copy of the index from the triplicate we've used)
```
[Answer]
# Jelly, 13 bytes
```
,²DS€=/
1Ç³#Ṫ
```
Input is 1-indexed. [Try it online!](http://jelly.tryitonline.net/#code=LMKyRFPigqw9Lwoxw4fCsyPhuao&input=&args=MTk)
### How it works
```
1Ç³#Ṫ    Main link. Argument: n (index)
1        Set the return value to 1.
   #     Execute ... until ... matches have been found.
 Ç         the helper link
  ³        n
    Ṫ    Extract the last match.
,²DS€=/  Helper link. Argument: k (integer)
,²       Pair k with k².
  D      Convert each to decimal.
   S€    Compute the sum of each list of base 10 digits.
     =/  Reduce by equality.
```
[Answer]
# Mathematica, 64 bytes
```
a=Tr@*IntegerDigits;Nest[NestWhile[#+1&,#+1,a@#!=a[#^2]&]&,1,#]&
```
Simple anonymous function. Zero-indexed.
[Answer]
## Haskell, 54 bytes
```
s=sum.map(read.pure).show
([x|x<-[1..],s x==s(x^2)]!!)
```
Usage example: `([x|x<-[1..],s x==s(x^2)]!!) 17` -> `289`.
```
s calculates the digit sum:
                    show     -- turn number into a string
     map(read.pure)          -- turn every character (the digits) in to a
                             -- one element string and convert back to integer
sum                          -- sum those integers
main function:
[x|x<-[1..]            ]     -- make a list of all x starting from 1
           ,s x==s(x^2)      -- where s x == s (x^2)
                        !!   -- pick nth element from that list
```
[Answer]
# Perl 6, ~~47~~ 46 bytes
```
{(grep {$_.comb.sum==$_².comb.sum},1..*)[$_]}
```
[Answer]
# Pyth, 15
```
e.fqsjZTsj^Z2TQ
```
1 byte thanks to DenkerAffe!
[Try it here](https://pyth.herokuapp.com/?code=e.fqsjZTsj%5EZ2TQ&input=13&debug=0) or run a [Test Suite](https://pyth.herokuapp.com/?code=e.fqsjZTsj%5EZ2TQ&input=0&test_suite=1&test_suite_input=1%0A2%0A3%0A4%0A5%0A6%0A7%0A8%0A9%0A10%0A11%0A12%0A13%0A14%0A15%0A16%0A17%0A18%0A19%0A20&debug=0).
Uses the 1-indexed option.
Naive implementation using `.f` which gets the first `n` numbers that match the given condition.
[Answer]
# JavaScript (ES6), ~~76 73~~ 72 bytes
```
n=>eval("for(q=s=>eval([...s+''].join`+`),i=1;q(i)!=q(i*i)||n--;i++);i")
```
I spent 30 minutes trying to get this to work until I realized I was outputting the wrong variable :|
This is zero-indexed.
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 8 bytes
```
↵'²"Ṡ≈;i
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyIiLCIiLCLihrUnwrJcIuG5oOKJiDtpIiwiIiwiMSJd)
Insights scraped from the [MathGolf answer](https://codegolf.stackexchange.com/a/185357/107299) and the [05AB1E answer](https://codegolf.stackexchange.com/a/164398/107299).
```
↵'²"Ṡ≈;i # Takes the number as input and returns the n-th number in the series, 0-indexed
↵        # 10**input
 '    ;  # Filter the implicit range [0..n]
  ²      # Square the input
   "     # Pair the square with the input
    Ṡ    # Vectorised sum
     ≈   # All equal?
       i # Index into the resulting list
```
[Answer]
# [MATL](https://esolangs.org/wiki/MATL), ~~24~~ 23 bytes
```
x`@2:^"@V!Us]=?@]NG<]1$
```
Uses 1-based input.
[**Try it online!**](http://matl.tryitonline.net/#code=eGBAMjpeIkBWIVVzXT0_QF1ORzxdMSQ&input=MTI)
```
x        % take inpout and delete it (gets copied into clipboard G)
`        %   do...while
  @      %   push loop iteration index: candidate number, n
  2:^    %   array [n n^2]
  "      %   for each element of that array 
    @    %     push that element 
    V!U  %     get its digits (to string, transpose, to number)
    Xs   %     compute their sum
  ]      %   end for each
  =      %   are the two sums equal?
  ?      %   if so
    @    %     the candidate number is valid: push it
  ]      %   end if
  NG<    %   is number of elements in stack less than input?
]        % if so, proceed with next iteration. End do...while. 
1$       % specify 1 input for implicit display: only top of stack
```
[Answer]
# PARI/GP 46 bytes
```
s=sumdigits;k=0;while(n,n-=!(s(k++)-s(k^2)));k
```
1-indexed
[Answer]
# Julia, ~~79~~ 66 bytes
```
f(n,x=0,i=1,s=c->sum(digits(c)))=x<n?f(n,x+(s(i)==s(i^2)),i+1):i-1
```
This is a recursive function that accepts an integer and returns an integer. It uses 1-based indexing.
We store a few things as function arguments:
* `n` : The input
* `x` : A counter for how many numbers with this condition we've found
* `i` : A number to check for the condition
* `s` : A function to compute the sum of the digits of its input
While `x` is less than the input, we recurse, incrementing `x` if `i` meets the condition and incrementing `i`. Once `x == n`, we return `i`, but we have to subtract 1 because it will have been incremented one too many times.
[Answer]
## Convex 0.2, ~~36~~ 35 bytes
Convex is a new language that I am developing that is heavily based on CJam and Golfscript. The interpreter and IDE can be found [here](https://github.com/GamrCorps/Convex). Input is an integer into the command line arguments. Indexes are one-based. Uses the **CP-1252** encoding.
```
1\{\__2#¶{s:~:+}%:={\(\)\}{)\}?}h;(
```
[Answer]
# Mathematica, ~~63~~ ~~60~~ ~~61~~ 59 bytes
```
Select[Range[9^#],Equal@@Tr/@IntegerDigits/@{#,#^2}&][[#]]&
```
~~While making this the other answer popped up but I'm beating them by a single byte and I'm posting this before that one gets golfed.~~ One indexed.
[Answer]
# Retina, 103 bytes
```
\d+
$*1 x
{`x+
$.0$*x¶$.0$*a¶$.0$*b
%`b
$_
a+|b+
$.0
\d
$*
+`1¶1
¶
1(.*)¶¶$|¶[^d]+
$1x
}`^ ?x
x
```
Definitely golfable.
Uses the [new Retina feature `%`](http://chat.stackexchange.com/transcript/message/28044230#28044230) for squaring (hence not working with the online version yet).
[Answer]
# Mathcad, ~~70~~ 50 bytes
Mathcad has no built in functions to convert a number to its digit string, so the user function d(a) does this job. A program then iterates through the positive integers, testing for equality of sums, until it has accumulated n numbers in the vector v. The program is evaluated using the = operator, which displays the result vector. (*Note that the whole program appears exactly as displayed below on the Mathcad worksheet*)
Updated program: 
Assumes default initialization of a to zero and makes use of fact that Mathcad returns the value of the last evaluated statement in a program.  
Makes use of evaluation order of expressions to increment variable a in the first summation (and which is then available for use in the sum of square)
[![enter image description here](https://i.stack.imgur.com/iMWfW.jpg)](https://i.stack.imgur.com/iMWfW.jpg)
Original program:
Returns a vector of all numbers up to n.
[![enter image description here](https://i.stack.imgur.com/Bp0VD.jpg)](https://i.stack.imgur.com/Bp0VD.jpg)
[Answer]
# [Ruby](https://www.ruby-lang.org/), 85 bytes
```
->n,*a{[*(1..).lazy.filter_map{_1 if _1.digits.sum==(_1**2).digits.sum}.take(n)][-1]}
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72kqDSpcsEiN9ulpSVpuhY3Q3Xt8nS0EqujtTQM9fQ09XISqyr10jJzSlKL4nMTC6rjDRUy0xTiDfVSMtMzS4r1iktzbW014g21tIw0kcRq9UoSs1M18jRjo3UNY2uhhpuAzDQy0NRLTUzOUEjJ51JQKCgtKVZQUjVKUdC1U1BNUVJQVYiON9RRcAOSsbFcqXkpEL0LFkBoAA)
[Answer]
# [Fig](https://github.com/Seggan/Fig), \$10\log\_{256}(96)\approx\$ 8.231 bytes
```
iFmN'=SxS*
```
[Try it online!](https://fig.fly.dev/#WyJpRm1OJz1TeFMqIiwiOCJd)
Could be ~7.4 bytes under normal sequence rules
## Explained
```
iFmN'=SxS*
 FmN'       # From an infinite list of natural numbers, keep only those where
      Sx    #   the digital sum of the number
     =      #   equals
        S*  #   the digital sum of the square of the number
i           # get the inputh item of the list
```
[Answer]
# [Pip](https://github.com/dloscutoff/pip), ~~22~~ ~~21~~ 20 bytes
```
($=$+*[_SQ_]FI,EE3a)
```
-2 Bytes thanks to [DLosc](https://codegolf.stackexchange.com/users/16766/dlosc)!
1-Indexed
Currently operates with a limited range for efficiency, replace `3` with `a` for infinite range
[Try It Online!](https://dso.surge.sh/#@WyJwaXAiLCIiLCIoJD0kKypbX1NRX11GSSxFRTNhKSIsIiIsIiIsIjIwIl0=)
How?
```
($=$+*[_SQ_]FI,EE3a)
                EE3    - 10 to the power of 3
               ,       - Range 0 to n
             FI        - Filter: keep items which return truthy
      [     ]          - Pair
       _               - Identity function
         SQ_           - Identity function squared
   $+*                 - Sum, vectorized at a depth of 1
 $=                    - Are they equivalent?
                   a   - Value at index Input
```
[Answer]
# Java 8, 113 bytes
```
n->{int r=0;for(;n>=0;)if((++r+"").chars().map(c->c-48).sum()==(r*r+"").chars().map(c->c-48).sum())n--;return r;}
```
0-indexed
**Explanation:**
[Try it online.](https://tio.run/##hY9LTsMwEIb3nGKU1QyWLYRYIExyA7rpsrAwbkJdkkk0dipVVc4e7LZ7pHk/pO8/upPTx/3v6nsXI3y4wJcHgMCplc75FjalvQ7AY4lMNk@W7Nlicil42ABDDSvr5lJOpH6y3ShouckVhQ5RKVFVRcYfnEQkM7gJvW68fnklE@cBqa5RHv87ItbaSptmYRC7rPaGMc3ffca405zGsIchK8FtksA/uy9HNxUFqgCGjAXhvX4uSSm6LgG255jawYxzMlN@TD1jUNXbZ6oUm6ye7tKX9Q8)
```
n->{           // Method with integer as both parameter and return-type
  int r=0;     //  Result-integer, starting at 0
  for(;n>=0;)  //  Loop as long as `n` is zero or positive
    if((++r    //   Increase `r` by 1 first
       +"").chars().map(c->c-48).sum()
               //   And if the sum of its digits
       ==(r*r+"").chars().map(c->c-48).sum())
               //   equals the sum of the digit of its square
      n--;     //    Decrease `n` by 1
  return r;}   //  Return the result
```
[Answer]
# [Perl 5](https://www.perl.org/) `-p`, 53 bytes
Includes `+1` for `-p`
1 based
```
#!/usr/bin/perl -p
$.++while$_-=!eval+("-($.) ".$.**2)=~s/\B/+/gr;$_=$.
```
[Try it online!](https://tio.run/##K0gtyjH9/19FT1u7PCMzJ1UlXtdWMbUsMUdbQ0lXQ0VPU0FJT0VPS8tI07auWD/GSV9bP73IWiXeVkXv/3/Tf/kFJZn5ecX/dQv@6/qa6hka6BkAAA "Perl 5 – Try It Online")
[Answer]
# TI-BASIC ~~66~~ 62 bytes
```
Ans→N:While X<N:IS>(A,A::A:prgmA:Ans→B:A²:prgmA:If B=Ans:IS>(X,N:End:A
sum(int(10fPart(Ans₁₀^(seq(⁻X-1,X,0,log(Ans
```
Input is \$n\$ in `Ans`.  
Output is the **1-indexed** \$n\$th term in the sequence.
Helper function generates the sum of the digits of the value in `Ans`.
**Examples:**
```
3:prgmCDGF1E
             10
5:prgmCDGF1E
             19
8:prgmCDGF1E
             55
10:prgmCDGF1E
             99
```
**Explanation:**
```
Ans→N:While X<N:IS>(A,A::A:prgmA:Ans→B:A²:prgmA:If B=Ans:IS>(X,N:End:A ;prgmCDGF1E
Ans→N            ;store the input in N
While X<N        ;loop until the Nth term has been reached
IS>(A,A:         ;add 1 to A
                 ; (Increment A and skip the next statement if A>A)
A                ;leave A in Ans
prgmA            ;call the helper program below
Ans→B            ;store the result of the helper program in B
A²               ;square A and leave the result in Ans
prgmA            ;call the helper program below
                 ; (result is in Ans)
If B=Ans         ;if the two results are equal
IS>(X,N          ;add 1 to X
                 ; (Increment X and skip the next statement if X>N)
End
A                ;leave A in Ans
                 ;implicit print of Ans
sum(int(10fPart(Ans₁₀^(seq(⁻X-1,X,0,log(Ans   ;prgmA
                      seq(⁻X-1,X,0,log(Ans    ;generate a list...
                                              ; using X as the variable,
                                              ; starting at 0,
                                              ; ending at the log of Ans,
                                              ; and evaluating "⁻X-1" for each element
                                              ; (implicit increment of 1)
                   ₁₀^(                       ;raise 10 to the power of each element
                Ans                           ;multiply each element by the input
          fPart(                              ;remove the integer part from each element
        10                                    ;multiply each element by 10
    int(                                      ;round each element to the nearest integer
sum(                                          ;then sum the resulting list
```
---
**Note:** TI-BASIC is a tokenized language. Character count does ***not*** equal byte count.
[Answer]
# [J](http://jsoftware.com/), 62 bytes
```
[:{:({.@](>:@[,],[#~(=&(1#."."0@":)*:)@[)}.@])^:(#@]<1+[)^:_&1
```
[Try it online!](https://tio.run/##y/qvpKeepmBrpaCuoKNgoGAFxLp6Cs5BPm7/o62qrTSq9RxiNeysHKJ1YnWiles0bNU0DJX1lPSUDByUrDS1rDQdojVrgWo046w0lB1ibQy1o4HMeDXD/5pcqckZ@QoaaUoGmgqG2pl6Rgb/AQ "J – Try It Online")
1 indexed. J once again not performing well on these "nth of" tasks, because of the excessive bookeeping mechanics.
[Answer]
# APL(NARS), 49 chars, 98 bytes
```
r←h w;c
c←r←0
→2×⍳∼=/+/¨(⍎¨⍕)¨r,r×r+←1⋄→2×⍳w>c+←1
```
1-indexed, test:
```
  h¨⍳20
1 9 10 18 19 45 46 55 90 99 100 145 180 189 190 198 199 289 351 361 
```
[Answer]
# [MathGolf](https://github.com/maxbergmark/mathgolf), 10 bytes
```
♪╒gÆ‼Σ²Σ=§
```
[Try it online!](https://tio.run/##DcghEkBAAIbR/p3Gb1krOIyCwCgOIDmAGUEWzIiyRHeIvcjy4uvKoan7tgrBr4df5vqZ/Hi9232@W3HvIUSIGENCiiXDkaM/hWJkUIJSZFGGHMo/ "MathGolf – Try It Online")
## Explanation
To make this usable, I chose to present a version which calculates every number with this property below 1000, and fetches the correct item from that list. To have a solution which would work for any input size, the first byte could be replaced by `ú` (push 10\*\*TOS). Since the n:th term in the sequence is always less than \$10^n\$, the script would always succeed. However, this puts a practical limit on calculation that's very low. 
```
♪            push 1000
 ╒           range(1,n+1)
  gÆ         filter list using the next 5 operators
    ‼        apply next two commands to TOS
     Σ       sum(list), digit sum(int)
      ²      pop a : push(a*a) (square)
       Σ     sum(list), digit sum(int) (pushes the digit sum of the square)
        =    pop(a, b), push(a==b) (compares the two)
         §   get from array (returns the <input>th item from the filtered list
```
[Answer]
# JavaScript, ~~67~~ 66 bytes
I feel very rusty golfing in JS so I'm sure there's something I'm missing here.
1-indexed
```
n=>(g=x=>(h=y=>eval([...y+``].join`+`))(++x)-h(x*x)||--n?g(x):x)``
```
[Try it online!](https://tio.run/##DcRLCoMwEADQq7joYqZDArqsjT1El6UwQeMPSSQGGak9e9q3eLPd7dbGaU3Kh87l3mRvGhiM/B/NYRq32wVeWuuDmN96DpNnYkQgElQjyFXwPJXyjwEEb4LMuQ8RxJS13Kuyxjb4LSxOL2EAvnzky3q13TPZmKBC4kI1BVMPQoSYfw)
[Answer]
# [Python 3](https://docs.python.org/3/), ~~125~~ 124 bytes
```
def f(x,i=1,a=()):
 while len(a)!=x:
  if sum(int(j)for j in str(i))==sum(int(j)for j in str(i**2)):a+=i,
  i+=1
 print(i-1)
```
[Try it online!](https://tio.run/##dYxBCsIwEEX3OcV3N9NGMIobYQ4TMEOn1LSkEevpY3sAt@893vKtw5xvrT2TQmnzJsFHIeaHw2ewKWFKmSKfZNsJTLG@X2S50sg6F4ywjLUWMmaRf67rrvsx9mL@mPQSHJZylHYO3JTu7JTChdsP "Python 3 – Try It Online")
1-indexed
[Answer]
# [Japt](https://github.com/ETHproductions/japt), ~~15~~ 12 bytes
1-indexed
```
Èìx ¶X²ìx}iU
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=yOx4ILZYsux4fWlV&input=NQ)
```
Èìx ¶X²ìx}iU     :Implicit input of integer U
È                :Function taking an integer as argument X
 ì               :  To digit array
  x              :  Reduce by addition
    ¶            :  Is equal to
     X²ìx        :  Digit sum of X squared
         }       :End function
          iU     :Get the Uth integer that returns true
```
[Answer]
# [Factor](https://factorcode.org/) + `benchmark.ant lists.lazy`, 56 bytes
```
[ 1 lfrom [ dup sq [ sum-digits ] same? ] lfilter lnth ]
```
[Try it online!](https://tio.run/##JcwxDsIwEAXRPqf4FyCSWygoEQ0NoopSbBybWFk7Zr0pwuWNJap51Xiyukl9Pe@P2xkcipae6Xv8idVJcoxIumByyS6RZO0pKbI41SNLaL50nTF1gAF72SIGzHtG@TSUPZ7m8A7tNaJQdNdW9oHVCTi17VgtMaOvPw "Factor – Try It Online")
* `1 lfrom` Infinite lazy list of the positive integers
* `[ ... ] lfilter` Take the ones where...
* `dup sq [ sum-digits ] same?` ...the digit sum of the number and its square are the same
* `lnth` Take the nth one
[Answer]
# JavaScript, 60 bytes
```
n=>(g=x=>(s=x=>x&&x%10+s(x/10|0))(++x)-s(x*x)||n--?g(x):x)``
```
An alternate approach for the sum of digits. 0-indexed.
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~66~~ 65 bytes
-1 bytes thanks to [@ceilingcat](https://codegolf.stackexchange.com/users/52904/ceilingcat)
```
i;s(n){n=n?n%10+s(n/10):0;}f(n){for(i=0;n-=s(++i)==s(i*i););n=i;}
```
[Try it online!](https://tio.run/##JYvBCsJADETv/YpQKGzcFrceG4M/4qVs2RLQKK3goeyvu6Y6l8nMvMRujrEUodUpbsp60aYP3tKxDzgEymkf0mNxwoG049V5L8jmchAkJGWhXERfcB9FHUK1VWCyH3B7LcDQk9mZ4RTs8B5/xJ/b9VwMTK5upgGa6ap1C9JCcoJIPyhXuXxiuo3zWrr3Fw "C (gcc) – Try It Online")
]