[Question]
  [
A *digit addition generator* of an integer `n` is any integer `x` that satisfy the equation `x + s(x) = n`, with `s(x)` being the sum of the digits of `x`. (We will work under base 10 for convenience.)
For example, a digit addition generator for `29` would be `19`, because `19 + (1 + 9) = 29`. Some numbers have more than one generator. An example might be `216`, which has generators of `198` and `207`.
Your objective is to generate the sequence `a_n` where `a_i` is the **lowest** digit addition generator of every non-negative integer `i`, and *anything other than a non-negative integer* if there is none for `i`.
The non-negative terms in your result should match the sequence [A096234](https://oeis.org/A096234). You may find [this paper](https://arxiv.org/pdf/2112.14365.pdf) related to the challenge.
Fewest bytes win; standard rules apply.
  
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal) `gM`, 28 [bitsv2](https://github.com/Vyxal/Vyncode/blob/main/README.md), 3.5 bytes
```
'∑+?=
```
[Try it Online!](https://vyxal.pythonanywhere.com/?v=2#WyJnPU0iLCIiLCIn4oiRKz89IiwiIiwiMCJd)
Outputs an empty list for no result. I think (spoiler I did) I ninja'd someone in the process of writing this lol.
## Explained
```
'∑+?=
'      # filter the range [0, n] by:
 ∑+    #   sum of digits + x
   ?=  #   equals input? 
# g flag prints minimum. 
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 7 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
Ý.ΔDªOQ
```
Outputs `-1` if there is no result.
[Try it online](https://tio.run/##yy9OTMpM/f//8Fy9c1NcDq3yD/z/38gSAA) or [verify a few more test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfeWhlf8Pz9U7N8Xl0Cr/Q@sC/9fq/I82stQxMjTTMdAxBCEgNjLWsbQwN9Mx1AHKgMQsdAwtLWIB).
**Explanation:**
```
Ý        # Push a list in the range [0, (implicit) input-integer]
 .Δ      # Find the first value of this list that's truthy for, or -1 if none are:
   D     #  Duplicate the current value
    ª    #  Convert the first value to a list of digits,
         #  and append the duplicated number to this list
     O   #  Sum the list together
      Q  #  Check whether it's equal to the (implicit) input-integer
         # (after which the result is output implicitly)
```
[Answer]
# [PARI/GP](https://pari.math.u-bordeaux.fr), 44 bytes
```
f(n,i)=if(i>n,x,i+sumdigits(i)-n,f(n,i+1),i)
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m728ILEoMz69YMGCpaUlaboWN3XSNPJ0MjVtM9M0Mu3ydCp0MrWLS3NTMtMzS4o1MjV18yAKtA01gaqgelTT8os08hRsFQx0FAwNgERBUWZeCVBESUHXDkgAdWhqQhXDLAIA)
Returns `x` when there is no solution.
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 8 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
Outputs `-1` for no result.
```
ôÈ+ìxÃbU
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=9Mgr7HjDYlU&input=Mjk)
(Eventually) outputs `undefined` for no result.
```
@¶X+ìx}a
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=QLZYK%2bx4fWE&input=Mjk)
```
ôÈ+ìxÃbU     :Implicit input of integer U
ô            :Range [0,U]
 È           :Pass each through the following function
  +          :  Add
   ì         :  Convert to digit array
    x        :  Reduce by addition
     Ã       :End function
      bU     :First 0-based index of U
```
```
@¶X+ìx}a     :Implicit input of integer U
@            :Function taking an integer X as argument
 ¶           :  Test U for equality with
  X+         :    Add to X
    ì        :      Convert X to digit array
     x       :      Reduce by addition
      }      :End function
       a     :Get the first integer >=0 that returns true
```
[Answer]
# [APL (Dyalog Extended)](https://github.com/abrudz/dyalog-apl-extended), 21 bytes
Anoymous tacit prefix function. Requires 0-indexing (`⎕IO←0`).
```
⍸⊢<\⍤=0,⍨⍳+1⊥¨⍎¨∘⍕¨∘⍳
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNrShJzUtJTfn/qG@qp/@jtgkG/x/17njUtcgm5lHvElsDnUe9Kx71btY2fNS19BCQ1QckOmY86p0KpTf/TwNqAoo/6mp@1LvmUe@WQ@uNH7VNBBoXHOQMJEM8PIP/azzqXaWTdmiFJlCDoYERAA "APL (Dyalog Extended) – Try It Online")
`⍸` where do we find that
`⊢` the argument
`<\` is the first (lit. cum. right-ass. less red.)
`⍤` that:
 `=` equals
`0,⍨` zero appended to
`⍳` the range
`+` plus
`1⊥` the sum (lit. base-1 eval.)
`¨` of each of
`⍎` the evaluation
`¨` of each
`⍤` of:
 `⍕` the stringification
 `¨` of each
 `⍤` of:
  `⍳` the range
[Answer]
# [C (clang)](http://clang.llvm.org/), 58 bytes
*loops forever if there's no solution*
```
d,s;f(*i,n){for(*i=s=0;n-s;)for(s=d=++*i;d;d/=10)s+=d%10;}
```
[Try it online!](https://tio.run/##JY7BTsMwEETP8VesilLZjQMOB0S1OF/CJfLGraV0g@K0HKr8OmYLt5nZN6MNbZgGPpVCNmPUh2TZ3OO8iPLZO@Q2o3n47Mk3zSEhIb34zpnceKo7h1t5ShymK43wkVdK8/O5Vyrxqi5DYn2bExl1V5UkwBaWcUWlqu9zmkbQOQwc9a6mnYU9G@jBGRC4inovpAU2KO5rkfYfB20PNX2y8P9jj/smgyKvC4NDtZXX7u0nxGk45dLKSz68H38B "C (clang) – Try It Online")
# [C (clang)](http://clang.llvm.org/), 70 bytes
For comparison, this returns negative values when there's no solution.
```
g,o,l;f(*i,n){for(*i=g=-n;g++;*i=n+l?*i:-g)for(l=o=g;o;o/=10)l+=o%10;}
```
[Try it online!](https://tio.run/##LY7BTgMxDETPm6@wihYlTQK7IKGCm/IjXFZJk0YKTrXdcqn21wmuxMljz/hpvPVlotRaMtUUjHKbDalbrDMrl5wlTFoja9Llc5s/bFJ3s7jqElasz24cVNGu9uOAa3vI5Ms1HGF/WUKuT6eDEJkW8T1lkj81ByVuouMLkIH5uKAQHfNAEjgYEAj28MpTa1LAyS7KR44ZIIW8nWd@jXLTB7AH6MMXbcw/6e6vTGN5nYlZYm0v49uvj2VKl2a5j/O79z8 "C (clang) – Try It Online")
[Answer]
# [C++ (gcc)](https://gcc.gnu.org/), ~~71~~ \$\cdots\$ ~~66~~ 64 bytes
```
[](int&n){for(int m=n,d=n=0,t;m-d;)for(d=t=++n;t;t/=10)d+=t%10;}
```
[Try it online!](https://tio.run/##VdHRbpswFAbg@zyFxbQJCmhgm3StcW6mPUWSC2RMhtqYCMwULcqrj/02oKZIcHx8vmNhW10u6UmpqRptRxo57Y9ha@w3E92arndDcpYmqaWRWWLFOa1F5Aq1tDKOjbDCfpd5FtWxtF/zTNwnsfnSGvU@1pqUbTfYXlfn3cPcH61s1@82fumqNWF02xA8g61fX@diidqO6OsFma6JJLcsIWmekHwOdA5sDnwOBcpgWwRkzwhgPxDAXhAWlsNRuByQuhySQuagFDSHpYulsAyWwjKXwzJYCstgKSxbLIPlsAyWuxyWwzJYDstg@WI5bAHLYQuXwxawHLaA5bDFui3YLWwBu3U57JbehT8z1ZnBEvW76p/w1epN9/ujO6/gcP1FD9eXn3iLICGPOQuWbtwj8Tfcmlpf0ZaJZVjOtzG0f3W4XkMkSBz7ckTmG3OPa7do9QXxaVpjem3e@/rxATQkBJDYY@S2YVsz6o9yE9ro82oDVrMfU/7/VDdaUpbrT5ckIOkOH4yGOfXj9WS0lMPRzx9MMC9139ynf6p5r07DlKZYVJ7MGMe0@g8 "C++ (gcc) – Try It Online")
*Saved 6 bytes thanks to [c--](https://codegolf.stackexchange.com/users/112488/c)!!!*
[Answer]
# JavaScript, 49 bytes
Loops forever, in theory, if there's no result but, in practice, throws a recursion error.
```
n=>(g=x=>n-eval([x,...x+``].join`+`)?g(++x):x)`0`
```
[Try it online!](https://tio.run/##BcFBCoAgEADA7@xiSnSqQHtIBCuRooSJieypr9tMtM2@Zwm5yjZ3p3vSBrxmbZK8mr1h50EpxYLoUPEJiQTh5kF@jCsjjdRzCamCg2lB7D8)
[Answer]
# [Raku](https://raku.org/), 34 bytes
```
{first 0..$^n: {$_+.comb.sum==$n}}
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoJamYPu/Oi2zqLhEwUBPTyUuz0qhWiVeWy85PzdJr7g019ZWJa@29n9xYqWCBlCBkYGmnZ2eWtp/AA "Perl 6 – Try It Online")
Returns the `first` element of the range `0` through the input number `$^n`/`$n` such that the element `$_` plus the sum of its digits `.comb.sum` is equal to the input number. If there is no such number, `Nil` is returned.
[Answer]
# [R](https://www.r-project.org), ~~45~~ 46 bytes
*Edit: +1 byte to correctly handle input of zero, but then -1 byte thanks pajonk for removal of useless accidental space*
```
\(n){while(n-F-sum(F%/%10^(0:F)%%10))F=F+1;+F}
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72waMHSnJTEdNulpSVpuhY39WI08jSryzMyc1I18nTddItLczXcVPVVDQ3iNAys3DRVgSxNTTdbN21Da223Wqguc5ARGkaWmlwQhqEZlGUApY01FZQV8vIVivNzSksy8_MUUisyi0uKIdoXLIDQAA)
Tests increasing integers until it finds a solution, so loops forever if no solution exists.
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 8 bytes
```
x|msajdT
```
[Try it online!](https://tio.run/##K6gsyfj/v6ImtzgxKyXk/38jQzMA "Pyth – Try It Online")
Returns `-1` for no result.
### Explanation
```
x|msajdTdQQQ    # implicitly add dQQQ
                # implicitly assign Q = eval(input())
  m      Q      # map lambda d over range(Q):
     jdT        #   list the digits of d
    a   d       #   append d to this list
   s            #   sum the list
 |        Q     # short circuiting or, does nothing unless the input is 0, then [] -> 0
x          Q    # find the first index of Q in the mapped list (or xors with 0 for 0), returns -1 if not found
```
[Answer]
# [Arturo](https://arturo-lang.io), ~~40~~  35 bytes
```
$->x[0while[x<>+∑digits<=<=]->1+]
```
[Try it!](http://arturo-lang.io/playground?zkCRSL)
Causes an infinite loop when there is no result.
```
$->x[                  ; a function taking an integer x
    0                  ; push 0 to stack
    while[x<>          ; while x doesn't equal...
        <=<=           ; duplicate top of stack twice
        +∑digits       ; digit sum then add
    ]                  ; end while condition
    ->1+               ; increment top of stack (while body)
]                      ; end function
```
[Answer]
# [Elixir](https://elixir-lang.org/), 74 72 bytes
```
import Enum
c=& &1-?0
r=&find(1..&1,fn x->&1==x+sum map'#{x}',c end)||-1
```
[Try it online!](https://tio.run/##ZctBC4IwGIDhu7/iY8HcaA4/QcFgderQqZ8QphMGbslUGGS/fdUt6fw@rx5MMD5GY8eHn@HsFpu0igLF7JQnXtHeuI6hlBRF7yBkR4pKhf20WLDNmO6e4ZWKFrTr@LpmGC9Xadw06nZmn/49y1yA5wKG5q6HA5Dm5ghPfpyXrKg3oKj/BVZbghXh8Q0 "Elixir – Try It Online")
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), ~~89~~ ~~53~~ ~~49~~ 44 bytes
```
#&@@Pick[r=Range@#,r+Tr/@IntegerDigits@r,#]&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n2b7X1nNwSEgMzk7usg2KDEvPdVBWadIO6RI38EzryQ1PbXIJTM9s6TYoUhHOVbtv39aWrRbaV5ySWZ@npVVcU5@SV4sV0BRZl5JdJqCvoMCxARjA4PY/wA "Wolfram Language (Mathematica) – Try It Online")
Thanks to @ovs and @att!
[Answer]
# [Julia](https://julialang.org), ~~42~~ 37 bytes
```
~n=argmax(x->x+sum(digits(x))==n,0:n)
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m700qzQnM3HBgqWlJWm6FjdV6_JsE4vScxMrNCp07Sq0i0tzNVIy0zNLijUqNDVtbfN0DKzyNKGKg5UVXCsScwtyUq24HIoz8ssV6owMzbi4lBVCUotLirkcEouLU4tKFOoMFBRsbRUMEAJGliABQ0uEiLEBSMTIBGI0zD0A)
-5 bytes thanks to MarcMush: use `argmax` instead of `findfirst`
[Answer]
# Java, 85 bytes
```
n->{for(int i=-1;i++<n;)if((i+"").chars().map(d->d-48).sum()+i==n)return i;return-1;}
```
Outputs `-1` if there is no result.
[Try it online.](https://tio.run/##PZAxb4MwEIX3/IoTky2MVWiVQihZOjdLxjSDa0zrFA5km1RVxG@nNkkq@U728@l9T3cSZ5Gc6u9ZtsJaeBMaLysAjU6ZRkgFu/BcBJAkdKSlV6aVb9YJpyXsAKGaMdlemt4sM7pK0lLH8QuWVDeE6DiKKJdfwlhCeScGUifbOnnKKbdjR2isqwqpUW40CLq8XrzFNJeBM4wfrefccOde19D5oGTvjMbPw1HQa8g73inrXoVVG1Q/IfnheMkKlqVr9sDScHxlj6zIn9csZf4naDlLi3yiixHA/tc61fF@dHzwENciubvG0ebdRTFy@S/R206m@Q8)
**Explanation:**
```
n->{                   // Method with integer as both parameter and return-type
  for(int i=-1;i++<n;) //  Loop `i` in the range (-1,n]:
    if((i+"")          //   Convert `i` to a String
       .chars()        //   Then to an IntStream of codepoints
       .map(d->d-48)   //   Then to an IntStream of digits
       .sum()          //   And sum those digits together
             +i        //   Add integer `i`
               ==n)    //   And if it's equal to input `n`:
      return i;        //    Return `i` as result
  return-1;}           //  If no result is found, return `-1` instead
```
Using a recursive function which throws a `StackOverflowError` when there is no result is also **85 bytes**:
```
n->f(n,0)int f(int n,int i){return(i+"").chars().map(d->d-48).sum()+i==n?i:f(n,i+1);}
```
[Try it online.](https://tio.run/##jZHPb8IgFMfv/hUvPUFKG@uMqza6w7Kj7uBlifPAKJ1oCw1QjWn6r6@Duh@HXUbgAe/B@3x5HOmZRsf81LOSGgNrKmQ7AhDScl1QxmHjt4MDGPJW4sx5upEzG5Cw7GW0KpAkY5z5cHE7RLwVuNXcNloiEQYBjtmBaoNwXNEa5dEqj6Ypjk1TIRyK5VI@iIVPJMIEZ12feULdvJWCgbHUuumsRA6Vk4i2Vgv5vttTfJNXKD1wLTf2kRq@kPziNe/27WROJsmMjEniuxuTOzJP72ckIS7ifSlJ5mmHh0QAVl/bryXA9mosr2LV2Lh2RFtK9I0Ig8WrDUIP8lVzz5Ix@4nioUq@dYxadnCKKTs9n11VS3V50lpp4Br/n/T3fvCLGD6k6z9UbYWSpo9ejJmuPwE)
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 13 bytes
```
ＮθＩ⌊Φ⊕θ⁼θ⁺ιΣι
```
[Try it online!](https://tio.run/##S85ILErOT8z5/98zr6C0xK80Nym1SKNQ05oroCgzr0TDObG4RMM3My8ztzRXwy0zpwQo65mXXJSam5pXkpoCVKmj4FpYmphTrFGooxCQU1qskamjEAxUnKkJAdb//xsZmv3XLcsBAA "Charcoal – Try It Online") Link is to verbose version of code. Takes `i` as an input and outputs `None` if no generator exists. Explanation: Brute force approach.
```
Ｎθ              First input as an integer
      θ         First input
     ⊕          Incremented
    Φ           Filter on implicit range
          ι     Current value
         ⁺      Plus
            ι   Current value
           Σ    Digit sum
       ⁼        Equals
        θ       First input
   ⌊            Take the minimum
  Ｉ             Cast to string
                Implicitly print
```
23 bytes for a less inefficient version:
```
ＮθＩ⌊Φ…·⁻θ×⁹Ｌθθ⁼θ⁺ιΣ⌈⟦⁰ι
```
[Try it online!](https://tio.run/##LYzLCsIwFET3fkWWNxDBumiQLkWhYKWoO3FxLaG9kETzKv59jMWBWZ2ZM0zohxfqnFv7TvGczFN5cLxZ9Z5shD2GCB1ZMsnAkXQstLWDToFmdUE7qh9NAZxgNzIqwE6wk7JjnIqFc8Fc6cEl1MumL08gwa5F1@Fn0d43gtGD/9PkXNVSym1V5/Wsvw "Charcoal – Try It Online") Link is to verbose version of code. Explanation: Starts checking for generators starting from `i` minus `9` times the number of digits of `i`.
28 bytes for a more efficient version:
```
ＮθＩ⌊ΦＥＬθ⁻⁻θ﹪×⁵θ⁹×⁹ι⁼θ⁺ιΣ⌈⟦⁰ι
```
[Try it online!](https://tio.run/##LY3NasMwEITvfQofZXBgV1r9kWNooVCXQHsrPaiJSQSyHdtSyNurcpI9DMzOfMzh7ObD6ELO78Mlxc/U/3Uzm@rty372Q2Q7t0TW@sH3qWdvPsSStu7CPrrhFM@l2FQlTQt76FTseExhZN@@7xYmm2qt2LrI42ObyterfZ2SC3diHwrpm@qrTLTudp/6gdL7rZ@3zdmgkchJcUmouSCSIKTkGoG4skIDCa0ASmSUEVoaIrCkLFhQWiOalbIoyApURnLkqPLmGv4B "Charcoal – Try It Online") Link is to verbose version of code. Explanation: As above, but only checks for generators which when doubled are equivalent to `i` modulo `9` (because `i` equals the generator plus its digit sum but both the generator and the digit sum are equivalent modulo `9`) although it actually computes the maximum possible generator by subtracting `5i` reduced modulo `9` from `i`.
[Answer]
# [C# (.NET Core)](https://www.microsoft.com/net/core/platform), 73 72 bytes
```
n=>{for(int i=-1;i++<n;)if((i+"").Sum(d=>d-'0')+i==n)return i;return-1;}
```
[Try it online!](https://tio.run/##XVA9a8MwEJ2tX3FkiYQ/iFNobRx7CbRLC4UMHUoHVZbTA1tqJTmlGP929xIylA56evfupHd3yqfKOr2MHs0RDj8@6KFif6PsEc3XP2lv@16rgNb47EEb7VBVjH2O7z0qUL30Hp6dPTo5sIlFV90HGeg6WWzhSaLhgkWUje5Ho3ZoQgIEDXRQL6Zups46TgJgneYVxvHOVAI7zjFerUR2GAfe1k2brjdrEWNdG@F0GJ0BrK6Ens1LRQb0k5bqA/hJOkByAaO/z2avb9O2TGCb3yawSSC/nDNsbxIoizuScyJUcckUBGUxU9tRtKfRba@zF4dB04Y07zgKQXYzm5df "C# (.NET Core) – Try It Online")
This is a C# port of this [answer](https://codegolf.stackexchange.com/questions/261861/lowest-digit-addition-generator/261871#261871). All the kudos goes to Kevin Cruijssen.
I really like that .NET's `sum` is taking a lambda to avoid the common map followed by sum!
[Answer]
# [Python 3](https://docs.python.org/3/), 63 bytes
```
g=lambda n:min(x for x in range(n)if x+sum(map(int,str(x)))==n)
```
[Try it online!](https://tio.run/##DcgxDoAgDAXQq3Rso5NOmnCYGhWbyIcAJnh69I0vvfWKmHv37taw7UpYg4EbnTFTIwNlhT8YYie1oTyBgyY21LHUzE1EnIP0lP9iz9Mi0j8 "Python 3 – Try It Online")
[Answer]
# [Python 3](https://docs.python.org/3/), 56 bytes
```
f=lambda n,o=0:(o+sum(map(int,str(o)))==n)*o or f(n,o+1)
```
[Try it online!](https://tio.run/##PcpBCoAgEAXQfadwOT9dZEFQ4GGMkIJ0RG3R6adWLR@8/LSD0yQS3OXjtnuVDLthJdb1jhR9pjM1U1shBuBcQs@Kiwr0RW0huXyBAo12BrpfCyAv "Python 3 – Try It Online")
[Answer]
# [Fig](https://github.com/Seggan/Fig), \$11\log\_{256}(96)\approx\$ 9.054 bytes
```
[KFax'=#x+S
```
[Try it online!](https://fig.fly.dev/#WyJbS0ZheCc9I3grUyIsIjIxNiJd)
```
[            # The first item from
   a         # the range from 1 to
    x        # the input,
  F  '       # filtered by:
          S  #   the digit sum of n
         +   #   plus n
      =      #   is equal to
       #x    #   the program's input,
 K           # sorted (smallest to largest).
```
[Answer]
# Swift, ~~84~~ 80 bytes
```
{n in(0...n).map{($0,"\($0)".reduce($0){$0+$1.hexDigitValue!})}.first{$1==n}!.0}
```
Takes an `Int` in and returns an `Int`.
[Try it online!](https://tio.run/##FcaxCsIwEIDhV7mWDDnUIxUXhTi5@AJOLkUTPWiPkl5RCHn2WJf/@@cPRz3UISjEE9irKMLuDKvgaxZgsY6IBGnsp2yN27b3tdhSCs/lEf6fjduYjt7he@EX660fltAULBQ5zZpN572UhlypU2JRG@3@iFh/)
Ungolfed:
```
{ (n: Int) -> Int in
  (0...n) // a sequence of all integers from 0 to n, inclusive
    // the parens are needed to avoid parsing as 0...(n.map)
    .map { i in // transform each one
      ( // return a tuple of:
        i, // 0. the integer itself
        "\(i)".reduce(i) { $0 + $1.hexDigitValue! } // 1. the digit sum plus the number
        // technically, wholeNumberValue would be more correct than hexDigitValue
      )
    }
    .first { $1 == n }! // find the first one where the sum is the input
    .0 // and return the number that gave that sum
}
```
[Answer]
# [Perl 5](https://www.perl.org/) `-MList::Util=sum -pa`, 29 bytes
```
$_=0;$_++while"@F"-sum$_,/./g
```
[Try it online!](https://tio.run/##K0gtyjH9/18l3tbAWiVeW7s8IzMnVcnBTUm3uDRXJV5HX08//f9/I8t/@QUlmfl5xf91fX0yi0usrEJLMnNsgWqAAqZ6BoYG/3ULEgE "Perl 5 – Try It Online")
[Answer]
# [Desmos](https://desmos.com/calculator), 66 bytes
```
I=[0...n]
f(n)=I[[i+∑_{k=0}^imod(floor(i/10^k),10)fori=I]=n].min
```
Returns `undefined` if no solution exists.
[Try It On Desmos!](https://www.desmos.com/calculator/9esxyqdldh)
[Try It On Desmos! - Prettified](https://www.desmos.com/calculator/qz6ogtumcb)
[Answer]
# [Ruby](https://www.ruby-lang.org/), 46 bytes
```
1.step{|c|p (1..c).find{|x|x+x.digits.sum==c}}
```
[Try it online!](https://tio.run/##KypNqvz/31CvuCS1oLomuaZAQcNQTy9ZUy8tMy@luqaipkK7Qi8lMz2zpFivuDTX1ja5tvb/fwA "Ruby – Try It Online")
[Answer]
# [Thunno 2](https://github.com/Thunno/Thunno2) `M`, 5 [bytes](https://github.com/Thunno/Thunno2/blob/main/docs/codepage.md)
```
æDS+=
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m728JKM0Ly_faGm0kq9S7IKlpSVpuhbLDi9zCda2XVKclFwMFVqwyMgSwgIA)
#### Explanation
```
æDS+=  # Implicit input
æ      # Filter [1..input] by:
 D     #  Duplicate
  S    #  Sum digits
   +   #  Add
    =  #  Equals input?
       # Take the minimum
       # Implicit output
```
[Answer]
# Haskell, 52 bytes
```
a n=find((==n).ap(+)(sum.map digitToInt.show))[1..n]
```
[Try it online!](https://tio.run/##VY1BSwQxDIXv@RU5eGgRizugMgvjZb0I7klv4iHa7k7YNh3aLOKvHzvDXjYQeO8j72WkegoxzjOnKRfFXRYtObp9FvJwgS@k5HYjlSvwxlWvwJ7@vgNAIhYc0GfANjEolkD@VbTBReF2i@9aWI5494yNr3csGgr9KN7gWSJLqOgw0YSmjvm36UPJaf2A981R20utbXINABDKcGDxxgyDWEeTubWmnpNbijwfWT9yS7il0trPjXPyNc9dD93mEbqnB@j6/h8)
[Answer]
# [Scala](http://www.scala-lang.org/), 71 bytes
[Try it online!](https://tio.run/##TY5BS8NAEIXv/RVD6WEX06WJoElwC6IePIgH8aQiY7oJI8mm7I6ClPz2OE2tujCP5c2bbyZW2OLYv727iuEOycNuBvI@sYWqvPVs1yJgR2/XagXcg9emJr9RJAYZ7h84kG9Mh1v1ajBeU0OsTfzoTkhbK@nG8X24aaNTy1SPQt@4GjpZpTA0sYTLEPDr6YB50SU8epKF/@5gF/kKo4viTmGVFQlk6VkCqwTSqfaSnSZQ5Odip/KRxNTJRYpcT7S6D6COOLhY/qH1zz6ArdzBrVdxvjh2y2de7KrfQT3MD7hhtq9h/AY)
```
n=>(0 to n).find(i=>(i.toString.map(_.asDigit).sum+i)==n).getOrElse(-1)
```
]