[Question]
  [
Let's define a sequence: The **n digit summing sequence** (n-DSS) is a sequence that starts with **n**. If the last number was **k**, then the next number is **k + digit-sum(k)**. Here are the first few n-DSS:
```
1-DSS: 1, 2, 4, 8, 16, 23, 28, 38, 49, 62, 70...
2-DSS: 2, 4, 8, 16, 23, 28, 38, 49, 62, 70, 77...
3-DSS: 3, 6, 12, 15, 21, 24, 30, 33, 39, 51, 57...
4-DSS: 4, 8, 16, 23, 28, 38, 49, 62, 70, 77, 91...
5-DSS: 5, 10, 11, 13, 17, 25, 32, 37, 47, 58, 71...
6-DSS: 6, 12, 15, 21, 24, 30, 33, 39, 51, 57, 69...
7-DSS: 7, 14, 19, 29, 40, 44, 52, 59, 73, 83, 94...
8-DSS: 8, 16, 23, 28, 38, 49, 62, 70, 77, 91, 101...
9-DSS: 9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99...
```
For 1, this is [A004207](https://oeis.org/A004207), although the first few digits are different due to a slightly different definition. For 3, it's [A016052](https://oeis.org/A016052); for 9, [A016096](https://oeis.org/A016096).
Today's challenge is to find the lowest n digit sum sequence that a given number appears in. This is called the "Inverse Colombian Function", and is [A036233](https://oeis.org/A036233). The first twenty terms, starting with 1 are:
```
1, 1, 3, 1, 5, 3, 7, 1, 9, 5, 5, 3, 5, 7, 3, 1, 5, 9, 7, 20
```
Some other good test cases:
```
117: 9
1008: 918
```
You only have to handle integers greater than 0, and you can take input and output in any standard format. As usual, this is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so shortest answer in each language wins.
  
[Answer]
# [Haskell](https://www.haskell.org/), ~~104~~ ~~64~~ 63 bytes
**(-26 thanks to H.PWiz, additional -14 thanks to Sriotchilism O'Zaic, additional -1 thanks to cole)**
This is a function.
```
f x=[y|y<-[1..],x==until(>=x)(foldr((+).read.pure)<*>show)y]!!0
```
[Try it online!](https://tio.run/##FcxBDoMgEADAr6y3XdsS9Oz6EcOBRAhERIIaIenfaToPGKfPzYTQmoXCS/3W6bMMQqh3Yb7j5QPOXAjtEdaM@CKRjV5FurOhqZ9PdzxUVdfJtmsfgSFlHy/cdQIL/2iUitoP "Haskell – Try It Online")
---
Explanation:
```
(foldr((+).read.pure)<*>show)
```
Sequence of composited functions that returns y+digital sum of y. Converts to string first, then does some monad gymnastics to get the sum of the characters and the original number (thanks to Cole).
The `<*>` operator in this context has type and definition
```
(<*>) :: (a -> b -> c) -> (a -> b) -> c
f <*> g = \x -> f x (g x)
```
so we can write the above as
```
\x -> foldr ((+) . read . pure) x (show x)
```
This `read . pure` converts a `Char` into a number, so `(+) . read . pure :: Char -> Int -> Int` adds a digit to an accumulated value. This value is initialized to the given number in the fold.
```
until (>=x) {- digital sum function -} y
```
`until` repeatedly applies a function to its result (in this case, the y+digital sum y) until it meets a requirement specified by a function in the first argument. This gives the smallest y-DSS element that's greater or equal to x.
```
[y | y<-[1..]; x == {- smallest y-DSS element >= x -} ]
```
Infinite lazy list of y's such that the smallest y-DSS element >= x is actually x. Uses Haskell's list comprehension notation (which I'd also totally forgotten about, thank y'all).
```
f x = {- aforementioned list -} !! 0
```
First element of that list, which is the smallest y that satisfies the requirement of the challenge.
[Answer]
# [Python 2](https://docs.python.org/2/), ~~73~~ 71 bytes
-2 bytes thanks to [Erik](https://codegolf.stackexchange.com/users/41024/erik-the-outgolfer).
```
n=input();k=K=1
while n-k:K+=k>n;k=[k+sum(map(int,`k`)),K][k>n]
print K
```
[Try it online!](https://tio.run/##LU3LCoMwELzvVyyeFC0Y@8SS3uwlh156E0GrASU1hm2k9evTSHsYZpiZ3TGL7SeduXbqJA@CwGk@aDPbMDorLjiDdz88JeqNykXM1UV7u1Txax7DsTHhoG1SqzqKElGVPq3AkPdQOP8L/sd3mmUOiJaWlRDlR7a4LsKqW2ksFrdrQTTRr/Ag2SjHIIMt7GAPBzgCYx5pevoC "Python 2 – Try It Online")
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), 44 bytes
```
->\a{+(1...{a∈($_,{$_+.comb.sum}...*>a)})}
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoJamYPtf1y4msVpbw1BPT6868VFHh4ZKvE61Sry2XnJ@bpJecWluLVBGyy5Rs1az9n9xYqWCkkq8lYKSjh5Qd1p@kQJIo5GBjqGhuY6hgYGF9X8A "Perl 6 – Try It Online")
Naive solution that checks every sequence until it finds one that contains the input
### Explanation:
```
->\a{                                    }  # Anonymous code block taking input as a
     +(1...{                           })   # Find the first number
            a∈(                       )     # Where the input is an element of
                                ...         # The sequence
               $_,                          # Starting with the current number
                  {            }   # Where each element is
                   $_+             # Is the previous element plus
                      .comb.sum    # The digit sum
                                   *>a      # Until the element is larger than the input
```
[Answer]
# [Ruby](https://www.ruby-lang.org/), 51 bytes
```
->n{(1..n).find{|i|i+=i.digits.sum while i<n;i==n}}
```
[Try it online!](https://tio.run/##DcvRCoIwFADQd7/iIgy07LJFUFTrR8QHc1teWLdojgjnty9fztv5xPsvO513N54rhcg1OmIzJ0q01YSGHjQFDPEJ35G8BbryhbTmZcntZg172YBSxxUpTx3afhjBvCBxKgDecQpQCnkIZxCmBAEtN@Bw6L2vuO4Kyyb/AQ "Ruby – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 11 bytes
```
D+ƒ$Ð¡€œi⁸Ḣ
```
[Try it online!](https://tio.run/##ASAA3/9qZWxsef//RCvGkiTDkMKh4oKsxZNp4oG44bii////Ng "Jelly – Try It Online")
Full program.
[Answer]
# [MATL](https://github.com/lmendo/MATL), 18 bytes
```
`@G:"ttFYAs+]vG-}@
```
[Try it online!](https://tio.run/##y00syfn/P8HB3UqppMQt0rFYO7bMXbfW4f9/Q0NzAA "MATL – Try It Online") Or [verify the first 20 values](https://tio.run/##y00syflvZGCl5BDhVfE/wcHLSqmkxC3SsVg7tsxLt9bhf6zLfwA).
### Explanation
For input `i`, this keeps increqsing `n` until the first `i` terms of `n`-th sequence include `i`. It is sufficient to test `i` terms for each sequence because the sequence is increasing.
```
`         % Do...while
  @       %   Push iteration index, n. This is the firsrt term of the n-th sequence
  G:      %   Push [1 2 ... i], where i is the input
  "       %   For each (i.e., do the following i times)
    tt    %     Duplicate twice
    FYA   %     Convert to digits
    s     %     Sum
    +     %     Add to previous term. This produces a new term of the n-th sequence
  ]       %   End
  v       %   Concatenate all terms into a column vector
  G-      %   Subtract i, element-wise. This is the do...while loop condition (*).
}         % Finally (this is executed right before exiting the loop)
  @       %   Push current n. This is the output, to be displayed
          % End (implicit). A new iteration will start if all terms of (*) are nonzero
          % Display (implicit)
```
[Answer]
# [Forth (gforth)](http://www.complang.tuwien.ac.at/forth/gforth/Docs-html/), 106 bytes
```
: f
>r 0 begin 1+ dup begin dup i < while dup begin 10 /mod >r + r> ?dup 0= until repeat i = until rdrop
;
```
[Try it online!](https://tio.run/##TY1BDoIwEEX3nuLFLYqtGw0qHoSwUNtCE6RNA/H4tSXGsHozb@bnGxemft@ZjBgrDHVA8NSdHZEFava/JU@WK5/eDnrlpeDwdirnCkLNPZ/EjXmc7EDQXj@mFPwLFZznEo8CSaNcS2PbVCspA@WWHVuawTnfkl4M5ea1eClPFQvWUojzYhOzjl8 "Forth (gforth) – Try It Online")
### Code Explanation
```
: f                \ start a new word definition
  >r               \ store the input on the return stack for easy access
  0                \ set up a counter
  begin            \ start an indefinite loop
    1+ dup         \ add 1 to the counter and duplicate
    begin          \ start a 2nd indefinite loop
      dup i <      \ check if current value is less than the input value
    while          \ if it is, continue with the inner loop
      dup          \ duplicate the current value
      begin        \ innermost loop, used to get the digit-wise sum of a number
        10 /mod    \ get quotient and remainder of dividing by 10
        >r + r>    \ add remainder to current list value
        ?dup 0=    \ check if quotient is 0
      until        \ end the innermost loop if it is
    repeat         \ go back to the beginning of the 2nd loop
    i =            \ check if the "last" value of the current list = the input value
  until            \ if it does, we're done
  rdrop            \ remove the input value from the return stack
;                  \ end the word definition    
```
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 13 bytes
```
fqQ.W<HQ+ssM`
```
[Try it here](https://pythtemp.herokuapp.com/?code=fqQ.W%3CHQ%2BssM%60&input=117&debug=0) or check out the **[test suite](https://pythtemp.herokuapp.com/?code=fqQ.W%3CHQ%2BssM%60&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%0A117%0A1008&debug=0)**.
---
### How it works
```
fqQ.W<HQ+ssM`     Full program. Takes input Q from STDIN, writes to STDOUT.
f{...}            Loop over 1,2,3,... and find the first number to yield truthy results when
                     applying the function {...} (whose variable is T = the current integer).
 qQ.W<HQ+ssM`     The function {...}, which will be analysed separately.
   .W             Functional while. While condition A is true, do B.
     <HQ          Cond. A (var: H - starts at T): Checks if H is less than Q.
        +ssM`     Func. B (var: G - G & H are the same): If A, G & H become G+digit sum(G)
                  The last value of this functional while will be the least possible number N
                  in the T-DSS that is greater than or equal to Q.
                  If N = Q, then Q ∈ T-DSS. Else (if N > Q), then Q ∉ T-DSS.
 q                That being said, check whether N == Q. 
```
In most languages, it would be easier to loop on the set of the natural numbers, find the first \$n\$ terms of the \$k\$-DSS (because the digit sum is always at least \$1\$ so the repeated addition of this type of quantity cannot result in a value smaller than \$n\$) and check if \$n\$ belongs in those first \$n\$ terms of the \$k\$-DSS. In Pyth, however, the available control-flow structures actually make it easier to generate terms until a certain condition is met, rather than a fixed number of terms.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 9 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
DS+)i$ƬṖṪ
```
A monadic Link accepting a positive integer `n` which yields a positive integer, `a(n)`, the Inverse Colombian of `n`.
**[Try it online!](https://tio.run/##y0rNyan8/98lWFszU@XYmoc7pz3cuer///@GBgYWAA "Jelly – Try It Online")** Or see the [test-suite](https://tio.run/##AUEAvv9qZWxsef//RFMrKWkkxqzhuZbhuar/xbzDh@KCrFpH//9saXN0KHJhbmdlKDEsIDIxKSkgKyBbMTE3LCAxMDA4XQ "Jelly – Try It Online").
### How
Effectively we work backwards, repeatedly looking for the value we added to until we cannot find one:
```
DS+)i$ƬṖṪ - Link: integer n
      Ƭ   - Repeat until a fixed point, collecting up:
     $    -   last two links as a monad - f(n):
   )      -     left links as a monad for each - [g(x) for x in [1..n]]:
D         -       decimal digits of x
 S        -       sum
  +       -       add x
    i     -     first (1-indexed) index of n in that list, or 0 if no found
       Ṗ  - pop of the rightmost value (the zero)
        Ṫ - tail
```
Using `13` as an example...
```
D  )  = [[1],[2],[3],[4],[5],[6],[7],[8],[9],[1,0],[1,1],[1,2],[1,3]]
 S    = [  1,  2,  3,  4,  5,  6,  7,  8,  9,    1,    2,    3,    4]
  +   = [  2,  4,  6,  8, 10, 12, 14, 16, 18,   11,   13,   15,   17]
    i 13 = .......................................... 11
    i 11 = .................................... 10
    i 10 = ............... 5
    i 5 = not found = 0 
    i 0 = not found = 0
    Ƭ -> [13, 11, 10, 5, 0]
    Ṗ =  [13, 11, 10, 5]
    Ṫ =               5
```
[Answer]
# [Python 2](https://docs.python.org/2/), 85 bytes
```
f=lambda n,a=[]:n in a and a.index(n)or f(n,[k+sum(map(int,`k`))for k in a]+[len(a)])
```
[Try it online!](https://tio.run/##RctBCsIwEIXhvaeY5QwN0nSjCD1JCHQkiYY00xAr6OljqwuXj/975b3eFxlaC@PM@eoYRPFo7EUgCjCwOOBjFOdfKLRUCCjKpO7xzJi5YJRVTWkiCltL34/tzOwFmSy1UjcAJmAk2EXcRWW5edRq0GQPPxFQ6xP9R9@fqX0A "Python 2 – Try It Online")
This certainly works for all the test cases, plus all of the 1..88 entries given at OEIS; but still I'm not quite sure it's *provably* correct. (This is one of my complaints regarding the Church Of Unit Testing :)).
[Answer]
# [MathGolf](https://github.com/maxbergmark/mathgolf), 13 bytes
```
╒môk(É∙Σ+=k/)
```
[Try it online!](https://tio.run/##y00syUjPz0n7///R1Em5h7dkaxzufNQx89xibdtsfc3//w25jLiMuUy4TLnMuAwNzbkMDQwsAA "MathGolf – Try It Online")
Great challenge! It caused me to find a few bugs within the implicit pop behavior of MathGolf, which added 1-2 bytes to the solution. 
## Explanation (using input \$3\$)
```
╒               range(1,n+1) ([1, 2, 3])
 mô             explicit map using 6 operators
   k(           push input-1 to TOS
     É          start block of length 3 (repeat input-1 times)
      ∙Σ+       triplicate TOS, take digit sum of top copy, and add that to second copy
                This transforms the array items to their respective sequences instead
                Array is now [1, 2, 4, 2, 4, 8, 3, 6, 12]
         =      get index of element in array (the index of 3 is 6)
          k/    divide by input (gives 2)
            )   increment (gives the correct answer 3)
```
To prove that this will always work, it is easy to see that `n <= input`, because `input` is the first element of the `input`th sequence. I have technically not proved that this solution is always valid, but it does pass every test case that I have tested. 
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 13 bytes
```
L.ΔIGÐSO+})Iå
```
[Try it online!](https://tio.run/##yy9OTMpM/f/fR@/cFE/3wxOC/bVrNT0PL/3/39DQHAA "05AB1E – Try It Online")
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/) 14.0+, ~~61~~ 48 bytes
```
Min@Position[Range@#//.j_/;j<#:>j+DigitSum@j,#]&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n2b73zczzyEgvzizJDM/LzooMS891UFZX18vK17fOstG2couSzukyMEzryQ1PbXIJTM9s6TYIUtHOVbtf0BRZl5JtLKuXZoDkFsXnJyYV1fNZahjpGOsY6JjqmOmY65joWOpw2VoaA4kDAwsuGr/AwA "Wolfram Language (Mathematica) – Try It Online")
As of version 14.0, [`DigitSum`](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn140.html#2094113477) finally exists. Since TIO is on 12.0.1, the linked version uses `Tr@IntegerDigits` (+8 bytes) instead.
[Answer]
# [Clean](https://github.com/Ourous/curated-clean-linux), 86 bytes
```
import StdEnv
$n=hd[i\\i<-[1..]|n==while((>)n)(\j=j+sum[toInt d-48\\d<-:toString j])i]
```
[Try it online!](https://tio.run/##PYzBCoJAFEX3fcVbhCilaCVqNK1qEbRz6bgYHKsR5xk6FkHf3jRNETwu91wep2prhlp2fGxrkEygFvLa9Qpyxfd4m0yRXHghKBUbv4iCoHwiIfeLaGvX3XroubQhzWwYZaG6Ayrg/iqllG/8tepy1Qs8Q1N6otS5YsZKwJXsClP4uBZh6QEhps/B3NJmbEtie2bxu8R2/P9kFo0BHMfooij5mLIfhWFqMUr1qzq17Dxo/3DUuwcyKarhDQ "Clean – Try It Online")
Expanded:
```
$ n                    // function `$` of `n` is
 = hd [                // the first
   i                   // integer `i`
  \\                   // for
   i <- [1..]          // each integer from 1 upwards
  |                    // where 
   n ==                // `n` is equal to
   while ((>) n) (     // the highest value not more than `n` from
    \j = j + sum [     // `j` plus the sum of
      toInt d - 48     // the digital value
     \\                // for each
      d <-: toString j // digit in the string form of `j`
     ]                 // where `j` is the previous term
    )                  // of the sequence
   i                   // starting with term `i`
  ]
```
It bothers me that `digitToInt d` is longer than `toInt d-48`
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 102 bytes
```
f(n,i,s){for(i=1;n^s;)for(s=i++;s<n;){char*p,j=0,l=asprintf(&p,"%d",s);for(;j<l;)s+=p[j++]-48;}n=~-i;}
```
[Try it online!](https://tio.run/##VY5NT8JAEIbP8is2S2p27WC6hdLishoPmJgoB@1NNCHdVpbg0rD1RMpfry0hzXh7Zub9mGz0nWVNUzALBhw/FvsDM0pI@@Uk7wanjO9LN7eSH7PN@nBTwlYFsFNrVx6MrQp2XQL1NG3dsjPI7XwnufNV@bH1/c/RJJG1VaeRkXUzNDbb/eqczF2lzf52cz8Y6rwwNifp4j1lS0gXb6@cXJJpwTzNV5UinvbcylJYQsGW/KxSqsMHSu/oqnp6fH4hzOa5JnTYXSmnfNCGkJ@1sYyT4@Dq3CBAcHnhEPEYxj1P0D6CqOcp0sQQ95wg/QxmPYsAmYXAQ4iixBhfJihYRFg2RTUixp4El85QQBhAGKAX4n/fBa1PJO2ibv4A "C (gcc) – Try It Online")
[Answer]
# JavaScript, 65 bytes
```
n=>eval('for(i=p=1;n-p;p=p>n?++i:p)for(j=p;j;j=j/10|0)p+=j%10;i')
```
[Try it online!](https://tio.run/##ZctBDsIgEIXhvadwYwrBKrjROE49S1PBMBCYtKYr747gysTVn7wvj8Z1XKbZ86tP@WGLw5JwsOsYRefyLDwyGkg9AyMP6a6Uv7JsQshAQEhHo99askLaGQ2@k6VxqLdwO2kISskppyVHe4j5KcJ@60SQEja/qzHnttf8idaXL9VWKx8 "JavaScript (Node.js) – Try It Online")
---
It also works as C, but cost one more byte
# [C (gcc)](https://gcc.gnu.org/), 66 bytes
```
i,p,j;f(n){for(i=p=1;n-p;p=p>n?++i:p)for(j=p;j;j/=10)p+=j%10;n=i;}
```
[Try it online!](https://tio.run/##dcuxDsIgFIXhvU9BmjSBABFcNF6pL@LS0NAAFm@qiUPTVxfBWacz/N@xcrI2Zy9QBHA0sdXdF@oNGg1JIqDBPl049ydktQSDECDsjFYMuQmdVpCMhy3Pg080MrI21cXyj@e9gsg5I7j49HS07UYie9KN19QKEgVx5cCg@Zm1PlRQ5j9R6vg1ZSva8tu62zA9snx9AA "C (gcc) – Try It Online")
[Answer]
# [C# (Visual C# Interactive Compiler)](http://www.mono-project.com/docs/about-mono/releases/5.0.0/#csc), ~~83~~, 82 bytes
```
n=>Enumerable.Range(1,n).First(x=>{for(;x<n;x+=(x+"").Sum(c=>c-48));return x==n;})
```
[Try it online!](https://tio.run/##ZYw9C8IwFAB3f0Xo9ELb0ICgkL5sdnLSwbmGRALtE/IBAfG3xzqKwy3HcSb2Jvo6ZTKjp9RtaOYYVkJ9orzaMN8XKy4zPSzIjriYfIgJCuqXewZQZSRVWoTSNg0X17yCQW36/ZFzFWzKgVhBJPXmVe1uwSd79mTBgdyCXyEPf2oYvp/6AQ "C# (Visual C# Interactive Compiler) – Try It Online")
[Answer]
# [Japt](https://github.com/ETHproductions/japt), ~~15~~ 14 bytes
The ternary to handle cases where `input=output` is annoying me!
```
@Ç?X±ìx:XÃøU}a
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=QMc/WLHseDpYw/hVfWE&input=MTE3)
```
@Ç?X±ìx:XÃøU}a     :Implicit input of integer U
@                  :A function taking an integer X as its argument
 Ç                 :  Map each Z in the range [0,U)
  ?                :    If Z>0
   X±              :      Increment X by
     ì             :      Convert X to digit array
      x            :      Reduce by addition
       :X          :    Else X
         Ã         :  End map
          øU       :  Contains U
            }      :End function
             a     :Return the first integer that returns true when passed through that function
```
[Answer]
# [cQuents](https://github.com/stestoltz/cQuents), 18 bytes
```
#|1:#bN;A
=A?Z+UDZ
```
[Try it online!](https://tio.run/##Sy4sTc0rKf7/X7nG0Eo5yc/akcvW0T5KO9Ql6v9/QwMA "cQuents – Try It Online")
## Explanation
```
=A?Z+UDZ      second line - helper function
               first input = A
               second input = n
=A            first term is A
  ?           mode=query, return true if n in sequence, false if n not in sequence
              each term in the sequence equals
   Z+          previous term +
     U   )                     sum (                          )
      D )                            digits (               )
       Z                                      previous term
#|1:#bN;A     main program
               first input = A  (user input)
               second input = n
#|1           n = 1
   :          mode=sequence, return the nth term in the sequence
    #     )   conditional - next term equals next N that evaluates to true
              N increments, any terms that evaluate to true are added to the sequence
               conditional (                      )
     b   )                   second line (      )
      N;A                                  N, A
```
[Answer]
# [Husk](https://github.com/barbuz/Husk), ~~14~~ 10 bytes
-4 thanks to @H.PWiz
```
V£⁰m¡SF+dN
```
[Try it online!](https://tio.run/##yygtzv7/P@zQ4keNG3IPLQx2007x@///v6E5AA "Husk – Try It Online")
[Answer]
# [Forth (gforth)](http://www.complang.tuwien.ac.at/forth/gforth/Docs-html/), 99 bytes
```
: f >r 0 begin 1+ dup begin dup i < while dup 20 for 10 /mod >r + r> next + repeat i = until r> . ;
```
[Try it online!](https://tio.run/##TU1LDoIwEN1zirdHsYMhgCgnYaNSoAm2pJbo7bEdlJhMOu/b6Yx1w77vwlqWEzrUFgI32SsNitHO05cEpHDGa1CjZJYK@B5I4PAwbSjGsDW0fLuA5CSvzlcumLVTY7ASVP6Gk09ntPS3EtwtqmiVkBIIrfGVX2I0ZvI@uz7ZgHZhjvxmDHLGJdNVyVjcMiXTVERE@fZxgzIiIYp/gYrlAw "Forth (gforth) – Try It Online")
Largely similar to [reffu's submission (106 bytes)](https://codegolf.stackexchange.com/a/188668/78410). The golfed parts are:
* Digit sum calculation (-6)
* Final cleanup (-1) by printing some garbage to stdout. (No problem because the result is returned on the top of the stack.)
### How it works
```
: dsum ( n -- n+digitsum ) \ Sub-function. Given n, add its digit sum to n.
  dup                      \ Copy n to form ( n m ) -> extract digits from m and add to n
  20 for                   \ Repeat 20 times (a 64-bit int is at most 20 digits)
    10 /mod >r + r>        \   n += m%10, m = m/10
  next + ;                 \ End loop and discard 0
: f ( n -- ans )    \ Main function.
  >r                \ Move n to the return stack, so it can be referenced using `i`
  0 begin 1+        \ Initialize counter and loop starting from 1
    dup begin       \   Copy the counter (v) and loop
      dup i < while \     break if v >= n
      dsum          \     v += digit sum of v
    repeat          \   End loop
  i = until         \ End loop if n == v
  r> . ;            \ Cleanup the return stack so the function can return correctly
                    \ `r> .` is one byte shorter than `rdrop`
```
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 26 bytes
```
ＮθＷ¬№υθ«ＵＭυ⁺κΣκ⊞υ⊕Ｌυ»Ｉ⊕⌕υθ
```
[Try it online!](https://tio.run/##TY29DsIgFEbn8hSMl6QOnRwYSUyaaNPEJ8CWCCk/LeXqYHx2BF1cz3dyvknLOAVpc@79imlAd1MRNsbJUxurKAwhgQjoE2BLN8YYfZHmIlcRnJN@rnS0uMPS0is6WIrBSTPiruvU@ykqp3xSM5yVv6dCv8abjNGUqJB7gn/rZH7ResV4zl13zIeH/QA "Charcoal – Try It Online") Link is to verbose version of code. Uses @ChasBrown's algorithm. If that turns out to be invalid, then for 29 bytes:
```
ＮθＷ¬№υθ«≔⊕ＬυηＷ‹ηθ≧⁺Σηη⊞υη»ＩＬυ
```
[Try it online!](https://tio.run/##Tc29DoIwFIbhGa6i42mCA5MDk2EiQdLoFVRsOE1KgZ4eHYzXXsGfxPEbnu/tUYd@0i6lxs8cOx4vJsAiq/yO1hkB3RShnthH4EIsUkrxyLMDkR08NL4PZjQ@miu0xg8RgaUsBK48@/rWEAG@qTjq@SNPdsAIyjEV4swj4A8pJtxC23jmKti1W2uKf/eySqks92l3cy8 "Charcoal – Try It Online") Link is to verbose version of code. Works by calculating the first member of each digit summing sequence not less than `n`. Explanation:
```
Ｎθ
```
Input `n`.
```
Ｗ¬№υθ«
```
Loop until we find a digit summing sequence containing `n`.
```
≔⊕Ｌυη
```
The next sequence begins with one more than the number of sequences so far.
```
Ｗ‹ηθ
```
Loop while the member of the sequence is less than `n`.
```
≧⁺Σηη
```
Add the digit sum to get the next member of the sequence.
```
⊞υη
```
Push the final member to the list.
```
»ＩＬυ
```
Print the number of lists computed until we found one containing `n`.
[Answer]
# [Red](http://www.red-lang.org), 103 bytes
```
func[n][m: 1 loop n[k: m until[if k = n[return m]s: k
foreach d to""k[s: s + d - 48]n < k: s]m: m + 1]]
```
[Try it online!](https://tio.run/##RYxBCsMgFAX3OcXDbSjEUGiQ9hLdfv4iJEqD8RvUnN8auuhuZhaT7FrfdiXunEF1pywkTMFAY4/xgJA3CDilbDttDh6v1pItZxIEzga@czHZeflgRYlKeWoxo296w31iwRPtkTlcox6auSZ72LlAMA6gI20Ccs2UYsalpWH3AwetH38ehql@AQ "Red – Try It Online")
[Answer]
# [CJam](https://sourceforge.net/p/cjam), 25 bytes
```
q~:T,{[){__Ab:++}T*]T&}#)
```
[Try it online!](https://tio.run/##S85KzP3/v7DOKkSnOlqzOj7eMclKW7s2RCs2RK1WWfP/f0NDcwA "CJam – Try It Online")
[Answer]
# [Gaia](https://github.com/splcurran/Gaia), 16 bytes
```
1⟨⟨:@<⟩⟨:Σ+⟩↺=⟩#
```
[Try it online!](https://tio.run/##S0/MTPz/3/DR/BVAZOVg82j@ShDj3GJtEKttly2QUgYqMDCwAAA "Gaia – Try It Online")
Returns a list containing the smallest integer.
```
1⟨	      ⟩#	% find the first 1 positive integers where the following is truthy:
	     =		% DSS equal to the input?
  	    ↺		% while
  ⟨:@<⟩			% is less than the input
       ⟨:Σ+⟩		% add the digital sum to the counter
```
# [Gaia](https://github.com/splcurran/Gaia), 16 bytes
```
1⟨w@⟨:):Σ++⟩ₓĖ⟩#
```
[Try it online!](https://tio.run/##S0/MTPz/3/DR/BXlDkDCStPq3GJt7UfzVz5qmnxkGpBWBsoamgMA "Gaia – Try It Online")
Uses the observation made by [Mr. Xcoder](https://codegolf.stackexchange.com/a/188662/67312). It's not shorter than the other, but it's an interesting approach nonetheless.
```
1⟨	      ⟩#	% find the first 1 integers z where:
  	     Ė		% the input (n) is an element of
  w@⟨:):Σ++⟩ₓ		% the first n terms of the z-th Digital Sum Sequence
```
# [Gaia](https://github.com/splcurran/Gaia), 16 bytes
```
┅ẋ⟨@⟨:):Σ++⟩ₓĖ⟩∆
```
[Try it online!](https://tio.run/##S0/MTPz//9GU1oe7uh/NX@EAxFaaVucWa2s/mr/yUdPkI9NAdEfb//@GBgYWAA "Gaia – Try It Online")
Third approach not using `N-find`, `#`, but still relying on the same observation as the middle approach. Returns an integer rather than a list.
[Answer]
## [Clojure](https://clojure.org/), 106 bytes
```
#(loop[j 1 i 1](if(= j %)i(if(< j %)(recur(apply + j(for[c(str j)](-(int c)48)))i)(recur(inc i)(inc i)))))
```
[Try it online!](https://tio.run/##NY3BCsIwEETv/YoBEXYRoSmCPeiXlB7CmkhCTcK2Pfj1sVacy7yBByNTjqu6WunhPDwONOVchgiDADNS8HRHxJHDF287kjpZlWwp0xsnRPJZB6F5UUQe6UwhLRC@9Mwc/nZIgm38ak/TUNEEetmyHZPkJHYBqU1Phw6dYQzGXGHath83v9YP "Clojure – Try It Online")
This is 99 bytes but results in Stack Overflow on larger inputs (maybe tweaking the JVM would help):
```
#((fn f[j i](if(= j %)i(if(< j %)(f(apply + j(for[c(str j)](-(int c)48)))i)(f(inc i)(inc i)))))1 1)
```
[Answer]
# [C# (Visual C# Interactive Compiler)](http://www.mono-project.com/docs/about-mono/releases/5.0.0/#csc), 75 bytes
```
n=>{int a=0,b=0;for(;b!=n;)for(b=++a;b<n;)b+=(b+"").Sum(x=>x-48);return a;}
```
[Try it online!](https://tio.run/##ZcixCsIwFIXh3aeonRLSSiKChdub0cnNwTk3JJDBFNIECuKzxziqw4H/fHYd7RrqpUQ7h5iHNu2xRtTPlp1BORBK8EtiQHuMwD9JKIQBmtslgYxE3/PDrTzYhnobTxOH5HJJsTPwqrC7p5DdNUTHPFOcf8PxF5Q6/5GUU7P6Bg "C# (Visual C# Interactive Compiler) – Try It Online")
[Answer]
# [ink](https://github.com/inkle/ink), ~~130~~ 127 bytes
```
-(l)
+(i)[+]->l
*(w)[{i}]
~temp n=w
-(o){n<i:
~n+=s(n)
->o
}{n>i:->w}{w}
==function s(n)
{n>9:
~return n%10+s(n/10)
}
~return n
```
[Try it online!](https://tio.run/##5YuxjsIwEET7/YptEDbBgVwHImmuuormmhOiiMCAhbMbOTZRFDm/Hqxr7iNO04zemzH0nD@Dc5q8Hdb4/XXEK@uOlh4fNV2tRkNt8B3e2KX6zPGHAzb1kPRLo2d0gdA/TIet47urG7R8qa0d8lkJKyETRp6ys6osrEQvT6OJZ5i8blqksgclWI50MHuYKCs7QRJUxRBHqsxeVX0c@whleQt08YYJfxdJ7tLBaR8cIS2KbZb4pthKiH94ngv4L/mANw "ink – Try It Online")
* `-3 bytes` by converting to a full program which takes unary input.
This feels too long to not be golfable.
### Ungolfed
```
// This program takes unary input. It passes through the same choice prompt as long as it recieves 1, and execution begins when it recieves 2
-(input_loop)
+(input_value)[+] -> input_loop                 // When this option (option 1) is selected, its read count is incremented. We can access this via the "input_value" variable. We then return to the prompt by going back to the "input_loop" gather
*(which_sequence)[{i}]                          // When this option (option 2) is selected, execution begins. Its read count also serves to keep track of which DSS we're checking.
~temp current_value = which_sequence            // The initial value for the n-DSS is n, of course.
-(sequence)                                     //
{current_value < input_value:                   // If we're still below the value we're looking for, we might find it.
    ~ current_value += digit_sum(current_value) // To get the next number, we add the current number's digit sum
    -> sequence                                 // Then we loop
}
{n > i: -> which_sequence}                      // If we get here, we're at or above our target number. If we're above it, we know it's the wrong sequence and move on to the next one by going back up to option 2. This increments its read count.
{which_sequence}                                // If we get here, we've found the target number, so we output the sequence's number.
// End of main stitch, program ends.
// A function to calculate the digit sum of a number
== function digit_sum(n) ==
{n > 9: // If given a number greater than 9, recurse
    ~ return (n % 10) + digit_sum(n / 10)
}
~ return n // Otherwise, return the input (it's a single digit)
```
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~80~~ ~~79~~ 78 bytes
```
i,j;r;v;f(n){for(r=v=n;i=--r;v=n-i?v:r)for(;i<n;)for(j=i;i+=j%10,j/=10;);n=v;}
```
[Try it online!](https://tio.run/##LY7BTsNADETv@YqoUqRddVZdp2mbYgwfUnpAKUGOxBYtKAeifHtwECc/e@wZd@G965ZFMXDmkXuX/NTfs8sySmKVEGwsKejz@JD9qrA@Jv6jQZR1K0NFEcNOKLLnJCPPy8erJuenQtN3mS9XmQg19mhwwBEntDjDbohANWgPakAH0BF0ArWgM@pVtSbGduZiDVutVKKlf@nP27132e/@ySRvj2x98ZmNe7epmlsZnsrq9pI2yBe9wvateM/FvPwC "C (gcc) – Try It Online")
-2 from ceilingcat
[Answer]
# [Perl 5](https://www.perl.org/) `-MList::Util=sum -p`, 57 bytes
```
map{$;=$_;"@F"-($_+=sum/./g)or$\||=$;while"@F">$_}1..$_}{
```
[Try it online!](https://tio.run/##K0gtyjH9/z83saBaxdpWJd5aycFNSVdDJV7btrg0V19PP10zv0glpqbGVsW6PCMzJxUkb6cSX2uopwckq///NzQwsPiXX1CSmZ9X/F/X11TPwNAASPtkFpdYWYWWZOaADPqvW5AIAA "Perl 5 – Try It Online")
]