[Question]
  [
Take a positive integer \$k\$ as input. Start with \$n := 1\$ and repeatedly increase \$n\$ by the largest integer power of ten \$i\$ such that \$i \le n\$ and \$i + n \le k\$.
Repeat until \$n = k\$ and return a list of all intermediate values of \$n\$, including both the initial \$1\$ and the final \$k\$.
During this process, growth will initially be limited by the former inequality, and only afterwards by the latter; the growth will take the form of an initial "expansion" period, during which \$n\$ is increased by ever-larger powers, followed by a "contract" period, during which \$n\$ is increased by ever-smaller powers in order to "zoom in" on the correct number.
## Test Cases
```
1 => [1]
10 => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
321 => [1,  2,  3,  4,  5,  6,  7,  8,  9,
        10, 20, 30, 40, 50, 60, 70, 80, 90,
        100, 200, 300, 310, 320, 321]
1002 => [1,   2,   3,   4,   5,   6,   7,   8,   9,
         10,  20,  30,  40,  50,  60,  70,  80,  90,
         100, 200, 300, 400, 500, 600, 700, 800, 900,
         1000, 1001, 1002]
```
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest answer (in bytes) wins.
  
[Answer]
# [Haskell](https://www.haskell.org/), 72 68 64 63 bytes
```
f=(1!)
c!t|t==c=[c]|t>c=c:(c+10^(pred.length.show.min c$t-c))!t
```
[Try it online!](https://tio.run/##DcfRCkAwFADQd19xVx62ZBlv6voRUbrGZGZxy4t/H@ftuOnerfcpLSiNUBkJfhmRsKfh5Y6QWkmFqUYZLztrb8PKTt/ufPSxBaCcS1JKcDqmvwjx2gJDDgs0tUkf "Haskell – Try It Online")
Thanks Sriotchilism O'Zaic for -4 bytes!
### Usage
```
f 321
[1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100,200,300,310,320,321]
```
### Explanation
```
c!t         -- c=current number, t=target number
 |t==c=[c]  -- Target is reached, return last number
 |t>c=c:(c+10^(pred.length.show.min c$t-c))!t
      c:                                        -- Add current number to list
                                min c$t-c       -- The minimum of the current number, and the difference between the current number and the target
                    length.show.                -- The length of this number
               pred.                            -- Minus 1
           10^(                          )      -- Raise 10 to this power
         c+                                     -- Add that to the current number
        (                                 )!t   -- Recursion
```
[Answer]
# JavaScript (ES6), 50 bytes
```
f=n=>n?[...f(n-(1+/(^10)?(0*$)/.exec(n)[2])),n]:[]
```
[Try it online!](https://tio.run/##Hc2xDoIwEADQ3a@4gYQ7bUuLmwaY/IqmBlKLQsjVgDEmhG@vxu1tb@ze3eLn4fmSHG8hpb7iqubGKqV6ZInmUODVaGpQ7zMqVPgEj0y2dESC3cm6dLZGgNECjuUfunQ71cf50vkHMlQ1@MhLnIKa4h3bbOUNpKwhW38DqTEOjDnktLVE6Qs "JavaScript (Node.js) – Try It Online")
## How?
### Theory
The following steps are repeated until \$n=0\$:
* look for the number \$k\$ of trailing zeros in the decimal representation of \$n\$
* decrement \$k\$ if \$n\$ is an exact power of \$10\$
* subtract \$x=10^k\$ from \$n\$
### Implementation
The value of \$x\$ is directly computed as a string with the following expression:
```
+---- leading '1'
|
1 + /(^10)?(0*$)/.exec(n)[2]
     \____/\___/
        |    |
        |    +---- trailing zeros (the capturing group that is appended to the leading '1')
        +--------- discard one zero if n starts with '10'
```
**Note**: Excluding the leading `'10'` only affects exact powers of \$10\$ (e.g. \$n=\color{red}{10}\color{green}{00}\$) but does not change the number of captured trailing zeros for values such as \$n=\color{red}{10}23\color{green}{00}\$ (because of the extra non-zero middle digits, `'10'` is actually not matched at all in such cases).
[Answer]
# [Python 2](https://docs.python.org/2/), 61 bytes
```
f=lambda k,n=1:n<k and[n]+f(k,n+10**~-len(`min(n,k-n)`))or[n]
```
[Try it online!](https://tio.run/##K6gsycjPM/r/P802JzE3KSVRIVsnz9bQKs8mWyExLyU6L1Y7TQMopG1ooKVVp5uTmqeRkJuZp5Gnk62bp5mgqZlfBFTzv6AoM69EIU3DUJMLzjRAsI2NUCQMjDT/AwA "Python 2 – Try It Online")
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), ~~48~~ 41 bytes
```
->\k{1,{$_+10**min($_,k-$_).comb/10}...k}
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoJamYKvwX9cuJrvaUKdaJV7b0EBLKzczT0MlXidbVyVeUy85PzdJ39CgVk9PL7v2f3FipUKahqGmNReUZQBnGhshCxsYaVr/BwA "Perl 6 – Try It Online")
### Explanation:
```
->\k{                                   }  # Anonymous code block taking k
     1,                             ...k   # Start a sequence from 1 to k
       {                           }       # Where each element is
        $_+          # The previous element plus
           10**      # 10 to the power of
                           .comb     # The length of
               min($_,k-$_)          # The min of the current count and the remainder
                                /10  # Minus one
```
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 30 [bytes](https://codegolf.meta.stackexchange.com/a/9429/43319 "When can APL characters be counted as 1 byte each?")[SBCS](https://github.com/abrudz/SBCS ".dyalog files using a single byte character set")
Anonymous tacit prefix function. Prints numbers on separate lines to stdout.
```
{⍺=⍵:⍺⋄⍺∇⍵+10*⌊/⌊10⍟⍵,⍺-⎕←⍵}∘1
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///v/pR7y7bR71brYD0o@4WENnRDuRrGxpoPerp0gdiQ4NHvfOBQjpASd1HfVMftU0A8mofdcww/J8G5vQBRT39H3U1H1pv/KhtIpAXHOQMJEM8PIP/pykYcunq6nIBaQMow9gIIWRgBAA "APL (Dyalog Unicode) – Try It Online")
`{`…`}∘1` anonymous infix lambda with 1 curried as initial \$n\$:
 `⍺=⍵` if \$k\$ and \$n\$ are equal:
  `⍺` return (and implicitly print) \$k\$
 `⋄` else:
  `⎕←⍵` print \$n\$
  `⍺-` subtract that from \$k\$
  `⍵,` prepend \$n\$
  `10⍟` \$\log\_{10}\$ of those
  `⌊` floor those
  `⌊/` minimum of those
  `10*` ten raised to the power of that
  `⍵+` \$n\$ plus that
  `⍺∇` recurse using same \$k\$ and new \$n\$
 
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 15 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
1[=ÐIαD_#‚ßg<°+
```
Port of [*@PaulMutser*'s (first) Haskell answer](https://codegolf.stackexchange.com/a/182584/52210), so make sure to upvote him!!
[Try it online](https://tio.run/##yy9OTMpM/f/fMNr28ATPcxtd4pUfNcw6PD/d5tAG7f//jY2MAQ) or [verify all test cases](https://tio.run/##yy9OTMpM/V@m5JlXUFpipaBkX6mj5F9aAuHo/DeMtj08ofLcRpd45UcNsw7PT7c5tEH7f@2hbfb/ow11DA10jI2MgZSBUSwA).
Outputs the numbers newline delimited.  
If it must be a list, I'd have to add 3 bytes:
```
X[DˆÐIαD_#‚ßg<°+}¯
```
[Try it online](https://tio.run/##AScA2P9vc2FiaWX//1hbRMuGw5BJzrFEXyPigJrDn2c8wrArfcKv//8zMjM) or [verify all test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKS/f@IaJfTbYcnVJ7b6BKv/Khh1uH56TaHNmjXHlr/X@fQlv/RhjqGBjrGRsZAysAoFgA).
**Explanation:**
```
1             # Push a 1 to the stack
 [            # Start an infinite loop
  =           #  Print the current number with trailing newline (without popping it)
  Ð           #  Triplicate the current number
   Iα         #  Get the absolute difference with the input
     D        #  Duplicate that absolute difference
      _       #  If this difference is 0:
       #      #   Stop the infinite loop
      ‚ß      #  Pair it with the current number, and pop and push the minimum
        g<°   #  Calculate 10 to the power of the length of the minimum minus 1
           +  #  And add it to the current number
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 19 bytes
```
1µ«³_$DL’⁵*$+µ<³$Ð¿
```
[Try it online!](https://tio.run/##y0rNyan8/9/w0NZDqw9tjldx8XnUMPNR41YtFe1DW20ObVY5POHQ/v9ABQYGxgA "Jelly – Try It Online")
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 51 bytes
```
Union@NestList[#+10^Floor@Log10@Min[s-#,#]&,1,s=#]&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n277PzQvMz/PwS@1uMQns7gkWlnb0CDOLSc/v8jBJz/d0MDBNzMvulhXWUc5Vk3HUKfYFkj/DyjKzCtR0HdI13dQqDbUMTTQMTYCUQZGtf//AwA "Wolfram Language (Mathematica) – Try It Online")
[Answer]
## Batch, 131 bytes
```
@set/an=i=1
:e
@if %n%==%i%0 set i=%i%0
@echo %n%
:c
@set/an+=i
@if %n% leq %1 goto e
@set/an-=i,i/=10
@if %i% neq 0 goto c
```
Takes input as a command-line parameter and outputs the list of numbers to STDOUT. Explanation:
```
@set/an=i=1
```
Start with `n=1` and `i=1` representing the power of 10.
```
:e
@if %n%==%i%0 set i=%i%0
```
Multiply `i` by 10 if `n` has reached the next power of 10.
```
@echo %n%
```
Output the current value of `n`.
```
:c
@set/an+=i
@if %n% leq %1 goto e
```
Repeat while `i` can be added to `n` without it exceeding the input.
```
@set/an-=i,i/=10
```
Restore the previous value of `n` and divide `i` by 10.
```
@if %i% neq 0 goto c
```
If `i` is not zero then try adding `i` to `n` again.
[Answer]
# [R](https://www.r-project.org/), 67 65 bytes
-2 bytes thanks to Giuseppe
```
k=scan();o=1;i=10^(k:0);while(T<k)o=c(o,T<-T+i[i<=T&i+T<=k][1]);o
```
Pretty simple. It takes a set of powers of 10 beyond what would be needed in reverse order `i`.
(I would prefer to use `i=10^rev(0:log10(k))` instead of `i=10^(k:0)` since the latter is computationally ineffecient, but golf is golf!).
Then in a while loop, applies the conditions to `i` and takes the first (i.e. largest); updates `n`, and appends to output
[Try it online!](https://tio.run/##K/r/P9u2ODkxT0PTOt/W0DrT1tAgTiPbykDTujwjMydVI8QmWzPfNlkjXyfERjdEOzM608Y2RC1TO8TGNjs22jAWqO2/JRD85wIA "R – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 12 bytes
```
1+«ạæḟ⁵«Ɗɗ¥Ƭ
```
[Try it online!](https://tio.run/##AScA2P9qZWxsef//MSvCq@G6ocOm4bif4oG1wqvGismXwqXGrP///zEwMDI "Jelly – Try It Online")
[Answer]
# [Pip](https://github.com/dloscutoff/pip), 27 bytes
```
Wa>Po+:y/t*Y1Ty>o|o+y>ay*:t
```
[Try it online!](https://tio.run/##K8gs@P8/PNEuIF/bqlK/RCvSMKTSLr8mX7vSLrFSy6rk////xkYmAA "Pip – Try It Online")
In pseudocode:
```
a = args[0]
o = 1
print o
while a > o {
  y = 1
  till y > o || o + y > a
    y *= 10
  o += y / 10
  print o
}
```
I'm pretty pleased with the golfing tricks I was able to apply to shorten this algorithm. By initializing, updating, and printing stuff in the loop header, I was able to avoid needing curly braces for the loop body. There's probably a golfier algorithm, though.
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 18 bytes
```
ÆT±ApTmTnU)sÊÉÃf§U
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=xlSxQXBUbVRuVSlzysnDZqdV&input=MzIx)
```
ÆT±ApTmTnU)sÊÉÃf§U     :Implicit input of integer U
Æ                      :Map the range [0,U)
 T±                    :  Increment T (initially 0) by
   A                   :  10
    p                  :  Raised to the power of
     Tm                :    The minimum of T and
       TnU             :      T subtracted from U
          )            :    End minimum
           s           :    Convert to string
            Ê          :    Length
             É         :    Subtract 1
              Ã        :End map
               f       :Filter
                §U     :  Less than or equal to U
```
[Answer]
# [C# (Visual C# Interactive Compiler)](http://www.mono-project.com/docs/about-mono/releases/5.0.0/#csc), ~~123~~ 122 bytes
```
m=>{var a=new[]{1}.ToList();int s;for(;(s=a.Last())<m;)a.Add(s+(int)Math.Pow(10,(int)Math.Log(s<m-s?s:m-s,10)));return a;}
```
[Try it online!](https://tio.run/##nY0xa8MwEIX3/gphOtxhRdjpVlkOWTK50KHQoXS4OLKrwTLolGYQ@u2uPXXpULIc7z2@j@t517NbTlffN85H2TmOW2hbMZhlMm36piDIeHv7@Ex1Vm/zhgDqFRKshzmABjakOtpmbCaNpI6XC3AJK4MvFL/U63yDupK/QzePwM204wM/r1fWFSLqYOM1eEE6L/rhPbhoO@ctPBYppQFqVMdxDHakaKEQhQSSZzQtledyrZhzLvAvr7pTfNrf/7La/0tdfgA "C# (Visual C# Interactive Compiler) – Try It Online")
[Answer]
# [Prolog (SWI)](http://www.swi-prolog.org), 142 bytes
```
L-D-M:-append(L,[D],M).
N-L-C-X-R-I:-I=1,C is X*10,N-L-C-C-R-1;D is C+X,(D<N,L-D-M,N-M-D-X-R-I;D>N,N-L-C-(X/10)-R-0;L-D-R).
N-R:-N-[]-0-1-R-1.
```
[Try it online!](https://tio.run/##bY09D4IwFEV3fwVj0Xex1Y36MbQLCXRgakIYTCSGhAABE35@bdFJnd7LuefdN05DNzwwL61zOTSKFLdxbPo7y6nSNRVxsjHIoWBRIkuRnQWpqJ0juxWc3pHykZA6ULWzxPTJ0Frm88LP9VTqi/n4zO4Fjz3kMmjl@qNMYVDV4BChLnHXsNAytc@m61mQPOE/6CgOfzT@Bd0L "Prolog (SWI) – Try It Online")
Explanation coming tomorrow or something
]